get_total_recieved method added

pull/1/head
moneroexamples 8 years ago
parent c617312ae4
commit ac41217f16

@ -120,6 +120,32 @@ public:
return 0; return 0;
} }
uint64_t
get_total_recieved(const uint64_t& account_id)
{
Query query = conn->query(XmrTransaction::SUM_XMR_RECIEVED);
query.parse();
try
{
StoreQueryResult sqr = query.store(account_id);
if (!sqr)
{
return 0;
}
Row row = sqr.at(0);
return row["total_received"];
}
catch (mysqlpp::Exception& e)
{
MYSQL_EXCEPTION_MSG(e);
return 0;
}
}
}; };
@ -276,8 +302,7 @@ public:
return false; return false;
} }
return mysql_tx->select(acc.id, txs);
return mysql_tx->select(acc.id, txs);
} }
bool bool
@ -287,6 +312,13 @@ public:
} }
uint64_t
get_total_recieved(const uint64_t& account_id)
{
return mysql_tx->get_total_recieved(account_id);
}
bool bool
update(XmrAccount& acc_orginal, XmrAccount& acc_new) update(XmrAccount& acc_orginal, XmrAccount& acc_new)
{ {

@ -131,6 +131,14 @@ struct XmrTransaction : public Transactions
%9q); %9q);
)"; )";
static constexpr const char* SUM_XMR_RECIEVED = R"(
SELECT SUM(`total_received`) AS total_received
FROM `Transactions`
WHERE `account_id` = %0q
GROUP BY `account_id`
)";
using Transactions::Transactions; using Transactions::Transactions;

Loading…
Cancel
Save