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 Ads History popup shows 2 entries for the same ad (even if only served once) #3960

Merged
merged 1 commit into from
Nov 13, 2019

Conversation

masparrow
Copy link
Contributor

@masparrow masparrow commented Nov 11, 2019

Fixes brave/brave-browser#6205

Submitter Checklist:

Test Plan:

As per brave/brave-browser#6205

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.

@masparrow masparrow added this to the 0.74.x - Nightly milestone Nov 11, 2019
@masparrow masparrow self-assigned this Nov 11, 2019
@masparrow masparrow marked this pull request as ready for review November 11, 2019 14:50
@masparrow masparrow force-pushed the issues/6205 branch 2 times, most recently from 6cb22fe to 3ca1fde Compare November 11, 2019 15:02
Copy link
Contributor

@emerick emerick left a comment

Choose a reason for hiding this comment

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

LGTM, a couple of minor nits.

vendor/bat-native-ads/src/bat/ads/internal/ads_impl.cc Outdated Show resolved Hide resolved
std::map<uint64_t, std::vector<AdsHistory>> ads_history;
base::Time now = base::Time::Now().LocalMidnight();

auto ad_history_details = client_->GetAdsShownHistory();

std::unique_ptr<AdHistoryFilter> adHistoryFilter = nullptr;
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor nit: The unique_ptr will automatically initialize to nullptr.

Copy link
Collaborator

Choose a reason for hiding this comment

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

adHistoryFilter should use snake_case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Spotted - I thought I'd fixed them all... sigh

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Minor nit: The unique_ptr will automatically initialize to nullptr.

Np, will address 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

vendor/bat-native-ads/src/bat/ads/internal/ads_impl.h Outdated Show resolved Hide resolved

std::deque<AdHistoryDetail> filteredAdHistoryDetails;

for (auto const& adsHistoryMap : filteredAdHistory) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like the const and auto should switch positions, but maybe that's just my personal preference... :-)

Copy link
Collaborator

Choose a reason for hiding this comment

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

agreed as consistency as we all seem to use const first at brave, google are 50/50

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

components/services/bat_ads/bat_ads_impl.cc Outdated Show resolved Hide resolved
vendor/bat-native-ads/include/bat/ads/ads.h Outdated Show resolved Hide resolved
components/services/bat_ads/bat_ads_impl.cc Outdated Show resolved Hide resolved
vendor/bat-native-ads/include/bat/ads/ads.h Outdated Show resolved Hide resolved
components/services/bat_ads/bat_ads_impl.cc Outdated Show resolved Hide resolved

std::deque<AdHistoryDetail> filteredAdHistoryDetails;

for (auto const& adsHistoryMap : filteredAdHistory) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

agreed as consistency as we all seem to use const first at brave, google are 50/50

@masparrow masparrow force-pushed the issues/6205 branch 2 times, most recently from d8c122a to 1bfd684 Compare November 12, 2019 09:55
@tmancey tmancey self-requested a review November 12, 2019 11:30
vendor/bat-native-ads/include/bat/ads/ads.h Outdated Show resolved Hide resolved
@@ -550,11 +551,28 @@ void AdsImpl::SetConfirmationsIsReady(
is_confirmations_ready_ = is_ready;
}

std::map<uint64_t, std::vector<AdsHistory>> AdsImpl::GetAdsHistory() {
std::map<uint64_t, std::vector<AdsHistory>> AdsImpl::GetAdsHistory(
const Ads::AdHistoryFilterType adHistoryFilterType) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: 4 spaces


std::deque<AdHistoryDetail> filtered_ad_history_details;

for (const auto& ads_history_map : filtered_ad_history) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need _map? Also ads_history_map is plural but filtered_ad_history is not, maybe intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Everything in here should be 'ad_history...' something so have fixed up accordingly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

components/services/bat_ads/bat_ads_impl.cc Outdated Show resolved Hide resolved
@masparrow masparrow force-pushed the issues/6205 branch 2 times, most recently from d3d700f to 51055ed Compare November 12, 2019 15:42
@tmancey tmancey self-requested a review November 12, 2019 15:45
std::map<uint64_t, std::vector<AdsHistory>> ads_history;
base::Time now = base::Time::Now().LocalMidnight();

auto ad_history_details = client_->GetAdsShownHistory();

std::unique_ptr<AdHistoryFilter> ad_history_filter;
switch (AdsHistoryFilterType) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you please raise an issue to refactor to use factories

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do - yep 👍

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 added CI/skip-android Do not run CI builds for Android CI/skip-ios Do not run CI builds for iOS CI/skip-linux labels Nov 12, 2019
@tmancey
Copy link
Collaborator

tmancey commented Nov 12, 2019

macOS failed to build, restarting macOS. All other platforms passed

@masparrow masparrow merged commit 7380696 into master Nov 13, 2019
@masparrow masparrow deleted the issues/6205 branch November 13, 2019 11:47
@masparrow masparrow removed CI/skip-android Do not run CI builds for Android CI/skip-ios Do not run CI builds for iOS CI/skip-linux labels Nov 13, 2019
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.

Ads History popup shows 2 entries for the same ad (even if only served once)
3 participants