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

Refactor time util and improve diagnostic logging with timezone friendly date and time for Brave Ads events #5444

Merged
merged 1 commit into from
May 8, 2020

Conversation

tmancey
Copy link
Collaborator

@tmancey tmancey commented May 2, 2020

Resolves brave/brave-browser#9199

Submitter Checklist:

Test Plan:

  • Confirm "Next payment date" on ads panel is working as expected

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.

@@ -5,7 +5,7 @@

#include "bat/ads/internal/frequency_capping/exclusion_rules/per_hour_frequency_cap.h"
#include "bat/ads/internal/frequency_capping/frequency_capping.h"
#include "bat/ads/internal/time.h"
#include "bat/ads/internal/time_util.h"
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't seem to be using anything defined in time_util.h, is that right? Are we including it just to get base/time/time.h? I see a bunch of similar includes of time_util.h.

@@ -31,7 +32,8 @@ std::string Reports::GenerateAdNotificationEventReport(
rapidjson::StringBuffer buffer;
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);

const std::string timestamp = Time::Timestamp();
const base::Time time = base::Time::Now();
const std::string timestamp = FriendlyDateAndTime(time, false);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I suppose this isn't really a "timestamp" anymore, but rather a formatted date string, but it looks like renaming the variable/JSON field would be painful.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Logs are being refactored as part of brave/brave-browser#6845 and brave/brave-browser#9533 so reports will be deprecated

@@ -1040,8 +1040,13 @@ uint64_t ConfirmationsImpl::GetAdNotificationsReceivedThisMonthForTransactions(
now.UTCExplode(&now_exploded);

for (const auto& transaction : transactions) {
if (transaction.timestamp_in_seconds == 0) {
// Workaround for Windows crash when passing 0 to UTCExplode
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

@@ -0,0 +1,76 @@
/* Copyright (c) 2020 The Brave Authors. All rights reserved.
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's a shame that we have to duplicate, but 🤷

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Totally agree, and I have raised brave/brave-browser#9611

Copy link
Contributor

@moritzhaller moritzhaller 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-linux labels May 4, 2020
@tmancey
Copy link
Collaborator Author

tmancey commented May 4, 2020

CI failed for iOS, macOS and Windows. Restarting

@tmancey tmancey added the CI/skip-ios Do not run CI builds for iOS label May 4, 2020
@tmancey
Copy link
Collaborator Author

tmancey commented May 4, 2020

CI failed for macOS and Windows. Restarting

@tmancey
Copy link
Collaborator Author

tmancey commented May 4, 2020

CI failed macOS, restarting macOS

@tmancey tmancey 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 May 5, 2020
@tmancey
Copy link
Collaborator Author

tmancey commented May 5, 2020

macOS failed on CI, restarting macOS

@tmancey tmancey force-pushed the issues/9199 branch 2 times, most recently from 9fac124 to dc34c5b Compare May 5, 2020 10:09
@tmancey
Copy link
Collaborator Author

tmancey commented May 8, 2020

Failed CI due to known iOS issue and rewards browser tests

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.

Refactor time util and improve diagnostic logging with timezone friendly date and time for Brave Ads events
3 participants