get_total_recieved updated

pull/93/merge
moneroexamples 6 years ago
parent 3d609e44da
commit a9cd46166b

@ -157,7 +157,7 @@ function(SETUP_TARGET_FOR_COVERAGE)
#COMMAND ${LCOV_PATH} -c -i -d . -o ${Coverage_NAME}.base #COMMAND ${LCOV_PATH} -c -i -d . -o ${Coverage_NAME}.base
# Run tests # Run tests
#COMMAND ${Coverage_EXECUTABLE} COMMAND ${Coverage_EXECUTABLE}
# Capturing lcov counters and generating report # Capturing lcov counters and generating report
#COMMAND ${LCOV_PATH} --directory . --capture --output-file ${Coverage_NAME}.info #COMMAND ${LCOV_PATH} --directory . --capture --output-file ${Coverage_NAME}.info
@ -169,7 +169,9 @@ function(SETUP_TARGET_FOR_COVERAGE)
#COMMAND ${GENHTML_PATH} -o ${Coverage_NAME} ${PROJECT_BINARY_DIR}/${Coverage_NAME}.info #COMMAND ${GENHTML_PATH} -o ${Coverage_NAME} ${PROJECT_BINARY_DIR}/${Coverage_NAME}.info
#COMMAND ${CMAKE_COMMAND} -E remove ${Coverage_NAME}.base ${Coverage_NAME}.total ${PROJECT_BINARY_DIR}/${Coverage_NAME}.info.cleaned #COMMAND ${CMAKE_COMMAND} -E remove ${Coverage_NAME}.base ${Coverage_NAME}.total ${PROJECT_BINARY_DIR}/${Coverage_NAME}.info.cleaned
COMMAND gcovr -r ${PROJECT_BINARY_DIR} --exclude='.*/ext/.*' --html --html-details -o /tmp/index.html COMMAND ${GCOVR_PATH} -v -s -r .. --exclude='.*/ext/.*' --exclude='.*/tests/.*' --html --html-details -o /tmp/index.html
#COMMAND ${GCOVR_PATH} -r .. -s --exclude='.*/ext/.*'
WORKING_DIRECTORY ${PROJECT_BINARY_DIR} WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
DEPENDS ${Coverage_DEPENDENCIES} DEPENDS ${Coverage_DEPENDENCIES}

@ -153,8 +153,8 @@ MysqlTransactions::exist(const uint64_t& account_id, const string& tx_hash_str,
} }
uint64_t bool
MysqlTransactions::get_total_recieved(const uint64_t& account_id) MysqlTransactions::get_total_recieved(const uint64_t& account_id, uint64_t& amount)
{ {
Query query = conn->query(XmrTransaction::SUM_XMR_RECIEVED); Query query = conn->query(XmrTransaction::SUM_XMR_RECIEVED);
query.parse(); query.parse();
@ -163,12 +163,11 @@ MysqlTransactions::get_total_recieved(const uint64_t& account_id)
{ {
StoreQueryResult sqr = query.store(account_id); StoreQueryResult sqr = query.store(account_id);
if (sqr.empty()) if (!sqr.empty())
return 0; {
amount = sqr.at(0)["total_received"];
Row row = sqr.at(0); return true;
}
return row["total_received"];
} }
catch (mysqlpp::Exception& e) catch (mysqlpp::Exception& e)
{ {
@ -176,7 +175,7 @@ MysqlTransactions::get_total_recieved(const uint64_t& account_id)
//throw e; //throw e;
} }
return 0; return false;
} }
MysqlPayments::MysqlPayments(shared_ptr<MySqlConnector> _conn): conn {_conn} MysqlPayments::MysqlPayments(shared_ptr<MySqlConnector> _conn): conn {_conn}
@ -586,10 +585,10 @@ MySqlAccounts::select_payment_by_id(const string& payment_id, vector<XmrPayment>
return mysql_payment->select_by_payment_id(payment_id, payments); return mysql_payment->select_by_payment_id(payment_id, payments);
} }
uint64_t bool
MySqlAccounts::get_total_recieved(const uint64_t& account_id) MySqlAccounts::get_total_recieved(const uint64_t& account_id, uint64_t& amount)
{ {
return mysql_tx->get_total_recieved(account_id); return mysql_tx->get_total_recieved(account_id, amount);
} }

@ -81,8 +81,8 @@ public:
bool bool
exist(const uint64_t& account_id, const string& tx_hash_str, XmrTransaction& tx); exist(const uint64_t& account_id, const string& tx_hash_str, XmrTransaction& tx);
uint64_t bool
get_total_recieved(const uint64_t& account_id); get_total_recieved(const uint64_t& account_id, uint64_t& amount);
}; };
class MysqlPayments class MysqlPayments
@ -183,8 +183,8 @@ public:
bool bool
update_payment(XmrPayment& payment_orginal, XmrPayment& payment_new); update_payment(XmrPayment& payment_orginal, XmrPayment& payment_new);
uint64_t bool
get_total_recieved(const uint64_t& account_id); get_total_recieved(const uint64_t& account_id, uint64_t& amount);
void void

@ -566,7 +566,9 @@ TEST_P(MYSQL_TEST_PARAM, GetTotalRecievedByAnAddress)
ACC_FROM_HEX(own_addr); ACC_FROM_HEX(own_addr);
uint64_t total_recieved = xmr_accounts->get_total_recieved(acc.id.data); uint64_t total_recieved;
EXPECT_TRUE(xmr_accounts->get_total_recieved(acc.id.data, total_recieved));
EXPECT_EQ(total_recieved, expected_recieved); EXPECT_EQ(total_recieved, expected_recieved);
} }

Loading…
Cancel
Save