Skip to content

Commit

Permalink
Fixes brave-browser/issues#2365, filters 0% publishers
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanml committed Dec 14, 2018
1 parent 99aecec commit a8cd36d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
7 changes: 7 additions & 0 deletions components/brave_rewards/browser/publisher_info_database.cc
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,10 @@ std::string PublisherInfoDatabase::BuildClauses(int start,
ledger::PUBLISHER_EXCLUDE_FILTER::FILTER_ALL_EXCEPT_EXCLUDED)
clauses += " AND pi.excluded != ?";

if (filter.percent == ledger::PUBLISHER_PERCENT_FILTER::FILTER_ZERO) {
clauses += " AND ai.percent >= ?";
}

for (const auto& it : filter.order_by) {
clauses += " ORDER BY " + it.first;
clauses += (it.second ? " ASC" : " DESC");
Expand Down Expand Up @@ -528,6 +532,9 @@ void PublisherInfoDatabase::BindFilter(sql::Statement& statement,
if (filter.excluded ==
ledger::PUBLISHER_EXCLUDE_FILTER::FILTER_ALL_EXCEPT_EXCLUDED)
statement.BindInt(column++, ledger::PUBLISHER_EXCLUDE::EXCLUDED);

if (filter.percent == ledger::PUBLISHER_PERCENT_FILTER::FILTER_ZERO)
statement.BindInt(column++, filter.percent);
}

bool PublisherInfoDatabase::InsertContributionInfo(const brave_rewards::ContributionInfo& info) {
Expand Down
1 change: 1 addition & 0 deletions components/brave_rewards/browser/rewards_service_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ void RewardsServiceImpl::GetCurrentContributeList(
filter.reconcile_stamp = ledger_->GetReconcileStamp();
filter.excluded =
ledger::PUBLISHER_EXCLUDE_FILTER::FILTER_ALL_EXCEPT_EXCLUDED;
filter.percent = ledger::PUBLISHER_PERCENT_FILTER::FILTER_ZERO;

ledger_->GetPublisherInfoList(
start,
Expand Down
6 changes: 6 additions & 0 deletions vendor/bat-native-ledger/include/bat/ledger/publisher_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ LEDGER_EXPORT enum PUBLISHER_EXCLUDE_FILTER {
FILTER_ALL_EXCEPT_EXCLUDED = 3
};

LEDGER_EXPORT enum PUBLISHER_PERCENT_FILTER {
FILTER_ZERO = 1,
FILTER_ALL_PERCENT = 100
};

LEDGER_EXPORT struct PublisherInfoFilter {
PublisherInfoFilter();
PublisherInfoFilter(const PublisherInfoFilter& filter);
Expand All @@ -62,6 +67,7 @@ LEDGER_EXPORT struct PublisherInfoFilter {
PUBLISHER_MONTH month;
int year;
PUBLISHER_EXCLUDE_FILTER excluded;
PUBLISHER_PERCENT_FILTER percent;
std::vector<std::pair<std::string, bool>> order_by;
unsigned int min_duration;
uint64_t reconcile_stamp;
Expand Down
2 changes: 2 additions & 0 deletions vendor/bat-native-ledger/src/bat/ledger/ledger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ PublisherInfoFilter::PublisherInfoFilter() :
month(PUBLISHER_MONTH::ANY),
year(-1),
excluded(PUBLISHER_EXCLUDE_FILTER::FILTER_DEFAULT),
percent(PUBLISHER_PERCENT_FILTER::FILTER_ALL_PERCENT),
min_duration(0),
reconcile_stamp(0) {}
PublisherInfoFilter::PublisherInfoFilter(const PublisherInfoFilter& filter) :
Expand All @@ -96,6 +97,7 @@ PublisherInfoFilter::PublisherInfoFilter(const PublisherInfoFilter& filter) :
month(filter.month),
year(filter.year),
excluded(filter.excluded),
percent(filter.percent),
order_by(filter.order_by),
min_duration(filter.min_duration),
reconcile_stamp(filter.reconcile_stamp) {}
Expand Down

0 comments on commit a8cd36d

Please sign in to comment.