Skip to content

Commit

Permalink
Merge pull request #752 from jasonrsadler/visit-exclude-recalc-core
Browse files Browse the repository at this point in the history
Recalculate auto-contribute table after exclude
  • Loading branch information
NejcZdovc authored Oct 29, 2018
2 parents cc3003e + 2abb270 commit 804ea39
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ deps = {
"vendor/boto": "https://github.com/boto/boto@f7574aa6cc2c819430c1f05e9a1a1a666ef8169b",
"vendor/python-patch": "https://github.com/svn2github/python-patch@a336a458016ced89aba90dfc3f4c8222ae3b1403",
"vendor/sparkle": "https://github.com/brave/Sparkle.git@c0759cce415d7c0feae45005c8a013b1898711f0",
"vendor/bat-native-ledger": "https://github.com/brave-intl/bat-native-ledger@0396fb47a0cfc55c0a7e271bae4c88c548e1574a",
"vendor/bat-native-ledger": "https://github.com/brave-intl/bat-native-ledger@3ce25e3820378021b935ab537e390916e91e823c",
"vendor/bat-native-rapidjson": "https://github.com/brave-intl/bat-native-rapidjson.git@86aafe2ef89835ae71c9ed7c2527e3bb3000930e",
"vendor/bip39wally-core-native": "https://github.com/brave-intl/bip39wally-core-native.git@9b119931c702d55be994117eb505d56310720b1d",
"vendor/bat-native-anonize": "https://github.com/brave-intl/bat-native-anonize.git@adeff3254bb90ccdc9699040d5a4e1cd6b8393b7",
Expand Down
16 changes: 14 additions & 2 deletions components/brave_rewards/browser/publisher_info_database.cc
Original file line number Diff line number Diff line change
Expand Up @@ -470,9 +470,15 @@ std::string PublisherInfoDatabase::BuildClauses(int start,
if (filter.min_duration > 0)
clauses += " AND ai.duration >= ?";

if (filter.excluded != ledger::PUBLISHER_EXCLUDE::ALL)
if (filter.excluded != ledger::PUBLISHER_EXCLUDE_FILTER::FILTER_ALL &&
filter.excluded !=
ledger::PUBLISHER_EXCLUDE_FILTER::FILTER_ALL_EXCEPT_EXCLUDED)
clauses += " AND pi.excluded = ?";

if (filter.excluded ==
ledger::PUBLISHER_EXCLUDE_FILTER::FILTER_ALL_EXCEPT_EXCLUDED)
clauses += " AND pi.excluded != ?";

for (const auto& it : filter.order_by) {
clauses += " ORDER BY " + it.first;
clauses += (it.second ? " ASC" : " DESC");
Expand Down Expand Up @@ -510,8 +516,14 @@ void PublisherInfoDatabase::BindFilter(sql::Statement& statement,
if (filter.min_duration > 0)
statement.BindInt(column++, filter.min_duration);

if (filter.excluded != ledger::PUBLISHER_EXCLUDE::ALL)
if (filter.excluded != ledger::PUBLISHER_EXCLUDE_FILTER::FILTER_ALL &&
filter.excluded !=
ledger::PUBLISHER_EXCLUDE_FILTER::FILTER_ALL_EXCEPT_EXCLUDED)
statement.BindInt(column++, filter.excluded);

if (filter.excluded ==
ledger::PUBLISHER_EXCLUDE_FILTER::FILTER_ALL_EXCEPT_EXCLUDED)
statement.BindInt(column++, ledger::PUBLISHER_EXCLUDE::EXCLUDED);
}

bool PublisherInfoDatabase::InsertContributionInfo(const brave_rewards::ContributionInfo& info) {
Expand Down
2 changes: 2 additions & 0 deletions components/brave_rewards/browser/rewards_service_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,8 @@ void RewardsServiceImpl::GetContentSiteList(
filter.min_duration = ledger_->GetPublisherMinVisitTime();
filter.order_by.push_back(std::pair<std::string, bool>("ai.percent", false));
filter.reconcile_stamp = ledger_->GetReconcileStamp();
filter.excluded =
ledger::PUBLISHER_EXCLUDE_FILTER::FILTER_ALL_EXCEPT_EXCLUDED;

ledger_->GetPublisherInfoList(start, limit,
filter,
Expand Down

0 comments on commit 804ea39

Please sign in to comment.