Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

minimum visits and minduration not persisting when changed #5824

Merged
merged 1 commit into from
Nov 28, 2016

Conversation

jkup
Copy link
Contributor

@jkup jkup commented Nov 23, 2016

  • Submitted a ticket for my issue if one did not already exist.
  • Used Github auto-closing keywords in the commit message.
  • Added/updated tests for this change (for new code or code which already has tests).
  • Ran git rebase -i to squash commits (if needed).

Fix #4822

Auditors @mrose17 @bsclifton

Two things here. One, we were multiplying by 1000 before storing the value but that causes a bug when the (now * 1000) value gets back to the UI. So instead, let's just keep the values in milliseconds.

The second thing is we initially store the minDuration and minimumVisits in ledgerData at the root but then we were saving it to ledgerData.synopsisOptions when it changed so the UI was grabbing the old value!

@bsclifton can you think of a good automated test for this? I know we chatted about it yesterday but I was struggling to implement something that makes sense!

Test Plan

  1. Start Brave
  2. Go to Preferences > Payments
  3. Click on Advanced Settings
  4. Change Minimum Duration to any new value
  5. Close and re-open the Advanced Settings modal
  6. Make sure the new value persists
  7. Do 4-6 with minimum visits as well

@jkup jkup added this to the 0.13.0 milestone Nov 23, 2016
Copy link
Member

@mrose17 mrose17 left a comment

Choose a reason for hiding this comment

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

i think if you add the two lines (without the *1000), it should be great, thanks!

@@ -143,15 +143,14 @@ const doAction = (action) => {

case settings.MINIMUM_VISIT_TIME:
if (action.value <= 0) break

synopsis.options.minDuration = action.value * 1000
Copy link
Member

Choose a reason for hiding this comment

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

in order for the ledger code to actually do the pruning, you'll need this line. just remove the "* 1000"

Copy link
Member

@bsclifton bsclifton Nov 26, 2016

Choose a reason for hiding this comment

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

@mrose17 this is seconds now right? (previously was milliseconds?) It does seem to be updated like you suggest (see next line)

updatePublisherInfo()
break

case settings.MINIMUM_VISITS:
if (action.value <= 0) break

synopsis.options.minPublisherVisits = action.value
Copy link
Member

Choose a reason for hiding this comment

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

in order for the ledger code to actually do the pruning, you'll also need this line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mrose17 ok so the problem right now in master is that it's first stored in ledgerData and then here it's added to ledgerData.synopsisOptions.

If it needs to be in synopsisOptions is the fix moving the initial value from the root of ledgerData?

@bsclifton bsclifton self-assigned this Nov 25, 2016
@bsclifton
Copy link
Member

bsclifton commented Nov 25, 2016

Will check this out tonite and give feedback 😄 (and respond to your question about automated test)

@jkup
Copy link
Contributor Author

jkup commented Nov 26, 2016

@bsclifton thanks for checking it out!

@mrose17 how is this approach? What if we don't set the duration and the minimum visits on the root object? And instead only set it / look for it in synopsisOptions?

If this doesn't work we can keep it in both places, it just seems unnecessary :)

@mrose17
Copy link
Member

mrose17 commented Nov 26, 2016

i agree it would be best to maintain the value in one place. in that case, i think that the place to keep the value is in var synopsis and to have the value copied from there in to/from ledgerData/appData. does that make sense?

@jkup
Copy link
Contributor Author

jkup commented Nov 26, 2016

@mrose17 ok so take minDuration and minPublisher visits out of synopsis.options and move them into synopsis?

@bsclifton
Copy link
Member

bsclifton commented Nov 26, 2016

The ledger code is distinctly different than the rest of the codebase, which can cause confusion (or at least it does for me). I think with a little work, we can make this more Redux friendly (and also unit-testable). Give me a few mins to cook up a change...

@bsclifton
Copy link
Member

bsclifton commented Nov 26, 2016

For this PR, it sounds like we need to update ledgerInfo to also have this new value and then trigger an update to persist the values in appState

Would you guys be able to work this out on Slack? 😄 Or if it's easier, we can do a Google hangout tomorrow (let me know, I'll set it up)

Copy link
Member

@mrose17 mrose17 left a comment

Choose a reason for hiding this comment

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

@jkup - how does this look to you?

@jkup
Copy link
Contributor Author

jkup commented Nov 28, 2016

@mrose17 LGTM!

@bsclifton assuming you ++ I think this one is ready to merge!

@mrose17
Copy link
Member

mrose17 commented Nov 28, 2016

agreed. @bsclifton - you get the "final say" !

appActions.changeSetting(settings.MINIMUM_VISIT_TIME, value)
}
if (value > 0) synopsis.options.minDuration = value * 1000
// for earlier versions of the code...
if ((value > 0) && (value < 1000)) synopsis.options.minDuration = value * 1000
Copy link
Member

Choose a reason for hiding this comment

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

👍

@bsclifton
Copy link
Member

bsclifton commented Nov 28, 2016

@jkup @mrose17 LGTM! Thanks for working it out 😄 I'll check out the tests here and merge

It could use a unit test to help prevent any regressions or unintended altering of the behavior 😊 @jkup if you would be willing to check that out, you could address with a follow up 😄 (logic could be broken out into ledgerUtil for easy testing). Shouldn't be too bad, just checking the value of settings.MINIMUM_VISIT_TIME in the assert. We can push on this though; in that case, just create a new issue marked w/ TEST to capture this (and tentatively put in a near future milestone)

@bsclifton
Copy link
Member

bsclifton commented Nov 28, 2016

Tests finished running; the ones which failed on travis-ci passed when I ran them locally.

npm run uitest -- --grep="navigationBar"
npm run uitest -- --grep="about:extensions"

Merging! 😄

@bsclifton bsclifton merged commit cbb3fc5 into master Nov 28, 2016
@bsclifton bsclifton deleted the minimum-visit branch November 28, 2016 21:49
@jkup
Copy link
Contributor Author

jkup commented Nov 28, 2016

@bsclifton thanks for the merge! created this #5887

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

Successfully merging this pull request may close these issues.

4 participants