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

use mojo types for PublisherInfo #2432

Merged
merged 2 commits into from
May 15, 2019
Merged

use mojo types for PublisherInfo #2432

merged 2 commits into from
May 15, 2019

Conversation

bridiver
Copy link
Collaborator

@bridiver bridiver commented May 13, 2019

Resolves brave/brave-browser#4425

Submitter Checklist:

Test Plan:

Reviewer Checklist:

  • New files have MPL-2.0 license header.
  • Request a security/privacy review as needed.
  • Adequate test coverage exists to prevent regressions
  • Verify test plan is specified in PR before merging to source

After-merge Checklist:

  • The associated issue milestone is set to the smallest version that the
    changes has landed on.
  • All relevant documentation has been updated.

@bridiver bridiver self-assigned this May 13, 2019
@bridiver bridiver force-pushed the publisher-info-mojom branch 4 times, most recently from 440a856 to 7f01dcc Compare May 14, 2019 02:22
@bridiver bridiver added this to the 0.67.x - Nightly milestone May 14, 2019
}
// TODO(bridiver) - this doesn't belong here
std::sort(site_list.begin(), site_list.end());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To solve this one I think we need to emit event to UI that list was normalized so that UI pulls it again. This way we don't need to sort it here, but UI decides if they want to pull. Down side is that data that we already have will need to be pulled from db again

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually I think the list normalization itself is a problem. @tmancey and I were discussing because calculated fields shouldn't be persisted in the db

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the percentage, etc... should be calculated at query time

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why would we like to do that on query time? then every time that we load rewards page we would nee to recalculate it even though that nothing changed

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is normalized every time publisher info is saved which happens very frequently. We are actually wasting far more cycles writing things that are never read. It can also easily lead to incorrect data or complicated data migrations when formulas change

Copy link
Collaborator Author

@bridiver bridiver May 14, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also what we're doing in the synopsis normalizer is trivial for the DB to do and doesn't require pulling all the records into memory (a problem for mobile). It is both more efficient and more reliable to do it at query time in the DB

@bridiver bridiver force-pushed the publisher-info-mojom branch 3 times, most recently from 6b6f474 to a78418f Compare May 14, 2019 21:39
using PublisherInfoPtr = mojom::PublisherInfoPtr;
using PublisherInfoList = std::vector<PublisherInfoPtr>;
// TODO - remove this
using PublisherInfoListStruct = PublisherInfoList;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like a left over here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if I removed all references to it

ContentSiteList site_list;
for (auto& publisher : *list) {
if (publisher.percent >= 1) {
site_list.push_back(PublisherInfoToContentSite(publisher));
Copy link
Member

@yrliou yrliou May 14, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these two lines supposed to be removed by this PR, or we moved this logic somewhere else?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed offline, this logic (the if (publisher.percent >= 1) part) was unintentionally removed when rebasing, let's put it back for now and move this UI logic to a suitable place later.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is fixed

@bridiver bridiver requested a review from tmancey May 14, 2019 23:38
Copy link
Collaborator

@tmancey tmancey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tmancey tmancey self-requested a review May 15, 2019 10:02
@NejcZdovc NejcZdovc requested a review from yrliou May 15, 2019 10:05
Copy link
Collaborator

@tmancey tmancey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM++

Copy link
Member

@yrliou yrliou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bridiver
Copy link
Collaborator Author

builds completed successfully, just an intermittent security check error not related to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

use mojo types for ledger PublisherInfo
4 participants