Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes old promotions not being displayed in the total (uplift to 1.10.x) #5573

Merged
merged 2 commits into from
May 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -509,10 +509,10 @@ void Database::MarkUblindedTokensAsSpent(
callback);
}

void Database::GetUnblindedTokensByTriggerIds(
void Database::GetSpendableUnblindedTokensByTriggerIds(
const std::vector<std::string>& trigger_ids,
ledger::GetUnblindedTokenListCallback callback) {
unblinded_token_->GetRecordsByTriggerIds(trigger_ids, callback);
unblinded_token_->GetSpendableRecordsByTriggerIds(trigger_ids, callback);
}

void Database::GetSpendableUnblindedTokensByBatchTypes(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ class Database {
const std::string& redeem_id,
ledger::ResultCallback callback);

void GetUnblindedTokensByTriggerIds(
void GetSpendableUnblindedTokensByTriggerIds(
const std::vector<std::string>& trigger_ids,
ledger::GetUnblindedTokenListCallback callback);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ void DatabaseUnblindedToken::OnGetRecords(
callback(std::move(list));
}

void DatabaseUnblindedToken::GetRecordsByTriggerIds(
void DatabaseUnblindedToken::GetSpendableRecordsByTriggerIds(
const std::vector<std::string>& trigger_ids,
ledger::GetUnblindedTokenListCallback callback) {
if (trigger_ids.empty()) {
Expand All @@ -441,8 +441,9 @@ void DatabaseUnblindedToken::GetRecordsByTriggerIds(
const std::string query = base::StringPrintf(
"SELECT ut.token_id, ut.token_value, ut.public_key, ut.value, "
"ut.creds_id, ut.expires_at FROM %s as ut "
"INNER JOIN creds_batch as cb ON cb.creds_id = ut.creds_id "
"WHERE cb.trigger_id IN (%s)",
"LEFT JOIN creds_batch as cb ON cb.creds_id = ut.creds_id "
"WHERE ut.redeemed_at = 0 AND "
"(cb.trigger_id IN (%s) OR ut.creds_id IS NULL)",
kTableName,
GenerateStringInCase(trigger_ids).c_str());

Expand Down Expand Up @@ -523,10 +524,10 @@ void DatabaseUnblindedToken::GetSpendableRecordListByBatchTypes(
const std::string query = base::StringPrintf(
"SELECT ut.token_id, ut.token_value, ut.public_key, ut.value, "
"ut.creds_id, ut.expires_at FROM %s as ut "
"INNER JOIN creds_batch as cb ON cb.creds_id = ut.creds_id "
"LEFT JOIN creds_batch as cb ON cb.creds_id = ut.creds_id "
"WHERE ut.redeemed_at = 0 AND "
"(ut.expires_at > strftime('%%s','now') OR ut.expires_at = 0) AND "
"cb.trigger_type IN (%s)",
"(cb.trigger_type IN (%s) OR ut.creds_id IS NULL)",
kTableName,
base::JoinString(in_case, ",").c_str());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class DatabaseUnblindedToken: public DatabaseTable {
ledger::UnblindedTokenList list,
ledger::ResultCallback callback);

void GetRecordsByTriggerIds(
void GetSpendableRecordsByTriggerIds(
const std::vector<std::string>& trigger_ids,
ledger::GetUnblindedTokenListCallback callback);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1568,10 +1568,10 @@ void LedgerImpl::MarkUblindedTokensAsSpent(
callback);
}

void LedgerImpl::GetUnblindedTokensByTriggerIds(
void LedgerImpl::GetSpendableUnblindedTokensByTriggerIds(
const std::vector<std::string>& trigger_ids,
ledger::GetUnblindedTokenListCallback callback) {
bat_database_->GetUnblindedTokensByTriggerIds(trigger_ids, callback);
bat_database_->GetSpendableUnblindedTokensByTriggerIds(trigger_ids, callback);
}

ledger::ClientInfoPtr LedgerImpl::GetClientInfo() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ class LedgerImpl : public ledger::Ledger {
const std::string& redeem_id,
ledger::ResultCallback callback);

void GetUnblindedTokensByTriggerIds(
void GetSpendableUnblindedTokensByTriggerIds(
const std::vector<std::string>& trigger_ids,
ledger::GetUnblindedTokenListCallback callback);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ class MockLedgerImpl : public LedgerImpl {

MOCK_METHOD1(GetAnonWalletStatus, void(ledger::ResultCallback));

MOCK_METHOD2(GetUnblindedTokensByTriggerIds, void(
MOCK_METHOD2(GetSpendableUnblindedTokensByTriggerIds, void(
const std::vector<std::string>& trigger_ids,
ledger::GetUnblindedTokenListCallback));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void PromotionTransfer::GetEligibleTokens(
ids.push_back(promotion->id);
}

ledger_->GetUnblindedTokensByTriggerIds(
ledger_->GetSpendableUnblindedTokensByTriggerIds(
ids,
tokens_callback);
}
Expand Down