-
Notifications
You must be signed in to change notification settings - Fork 873
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
Monthly statement can now be viewed from Rewards page #2733
Conversation
d710dca
to
a3a272d
Compare
439da23
to
6ca927e
Compare
762db26
to
9afe16b
Compare
edde833
to
63acf9e
Compare
6cff332
to
700c2b0
Compare
f07aa97
to
68bddc8
Compare
++ @kylehickinson for iOS |
4a1a87b
to
073be5c
Compare
browser/ui/webui/brave_rewards_ui.cc
Outdated
args->GetString(1, &year); | ||
int32_t month_conv; | ||
uint32_t year_conv; | ||
base::StringToInt(month, &month_conv); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we send these as integers from JavaScript?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -240,6 +243,10 @@ class RewardsService : public KeyedService { | |||
const std::string& type, | |||
const std::map<std::string, std::string>& args, | |||
GetShareURLCallback callback) = 0; | |||
virtual void GetMonthlyStatements( | |||
int32_t month, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason that month is signed and year is unsigned?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, month maps to ledger::MONTH
which can be -1 for ANY
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, gotcha.
".getElementsByTagName('tbody')[0].childNodes.length", | ||
content::EXECUTE_SCRIPT_DEFAULT_OPTIONS, | ||
content::ISOLATED_WORLD_ID_CONTENT_END); | ||
LOG(ERROR) << "=====table rows: " << acTableCountResult.ExtractInt(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a leftover debug statement or intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed.
for (let ix = 0; ix < monthsAvailable.length; ix++) { | ||
const date = new Date(parseInt(monthsAvailable[ix].split('_')[0], 10), parseInt(monthsAvailable[ix].split('_')[1], 10) - 1) | ||
const selectionStringValue = date.toLocaleString(navigator.language, { month: 'long' }) ; | ||
(ix + 1) === monthsAvailable.length ? monthsJson += `\"${monthsAvailable[ix]}\" : \"${selectionStringValue} ${date.getFullYear()}\"` : monthsJson += `\"${monthsAvailable[ix]}\" : \"${selectionStringValue} ${date.getFullYear()}\",` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: I think this would be clearer as an if-else, just given the length of this line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
transaction->probi = report->grants; | ||
transaction->category = 3; // placeholder for grants on statement | ||
base::Time parsed_time; | ||
std::string time_str = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been using base::StringPrintf
for this kind of string formatting, just FYI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. This does work better. changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit confused by this. Why do we have BalanceReport and also BalanceReportInfo and then converting again to TransactionStatementInfo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bridiver removed
073be5c
to
60a11b6
Compare
ab6d716
to
7ab14da
Compare
base::Time parsed_time; | ||
std::string time_str = | ||
base::StringPrintf("%s/1/%s", | ||
std::to_string(month).c_str(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably simpler to use the %u
format specifier instead of %s
, then you don't need to convert to string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 done
int32 category; | ||
}; | ||
|
||
struct MonthlyStatements { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should avoid having plural types. We can have a MonthlyStatement type and pass an array of them, but that array does not require a new type.
array<TransactionStatementInfo> transactions; | ||
}; | ||
|
||
struct AllTransactions { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above, I'm not sure this type is necessary at all
@@ -1644,4 +1649,161 @@ void LedgerImpl::FetchBalance(ledger::FetchBalanceCallback callback) { | |||
bat_wallet_->FetchBalance(callback); | |||
} | |||
|
|||
void LedgerImpl::OnGetAllTransactions( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trying to put all these different types together into a single query seems really overly complicated to me. I think we either need a new type with its own database query or do multiple queries to Ledger to get the different data types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These have been split out.
ledger::ACTIVITY_MONTH month, | ||
uint32_t year, | ||
double current_balance, | ||
ledger::MonthlyStatementCallback callback); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if MonthlyStatement is something that ledger should care about. It's just returning some range of Transactions. It also seems a bit strange to me that the method is called GetAllTransactions
/OnGetAllTransactions
when it isn't getting all the transactions. I'm not really sure what the method should be called though because I'm not following exactly what we are returning since AllTransactions
holds different types of data
double value; | ||
uint64 date; | ||
uint32 category; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is much better than a blank field for recurrent tips
ledger::PublisherInfoList list; | ||
|
||
if (!backend) { | ||
return all_transactions; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how do we tell the difference between an empty list and an error?
1680d5c
to
17c2382
Compare
@@ -279,6 +281,11 @@ class LEDGER_EXPORT Ledger { | |||
const ledger::MonthlyStatementCallback& callback, | |||
ledger::ACTIVITY_MONTH month, | |||
uint32_t year) = 0; | |||
|
|||
virtual void GetOneTimeTipsStatements( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should just add an optional month and year to the existing GetOneTimeTips method
browser/ui/webui/brave_rewards_ui.cc
Outdated
int32_t month = args->GetList()[0].GetInt(); | ||
int32_t year = args->GetList()[1].GetInt(); | ||
rewards_service_->GetMonthlyStatements( | ||
int32_t month = args->GetList()[1].GetInt(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this was already like this, but we should avoid args->GetList()[]
in favor of args->GetInteger(index, &month)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh... actually I guess not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// DEPRECATED, use GetList()::operator[]::GetInt() instead.
huh, wouldn't have thought that
7fd60a4
to
e3f81b0
Compare
Fixes brave/brave-browser#930
UI PR: brave/brave-ui#513
Submitter Checklist:
npm run lint
)git rebase master
(if needed).git rebase -i
to squash commits (if needed).Test Plan:
--
After merge it may be necessary to bring in a prepared profile that includes previous months. Required files need to be matching
publisher_info_db
,ledger_state
, andpublisher_state
Ensure that monthly dropdown operates correctly.
Note
Currently this PR allows for the current month to be displayed so long as wallet has had activity. Before merge, it is expected that only previous months from the current will be displayed.
Reviewer Checklist:
After-merge Checklist:
changes has landed on.
Additional Notes
Was attempting rebase and 403'd