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

Adds days since install calculation to the SDK #4491

Merged
merged 1 commit into from Sep 30, 2021

Conversation

tarikeshaq
Copy link
Member

@tarikeshaq tarikeshaq commented Sep 21, 2021

Part of https://mozilla-hub.atlassian.net/browse/SDK-384

Some important TODOs before this can land:

  • Add tests, for the changed behaviour and for targeting.. Will probably need to write an integration test to validate this
  • Add changelog
  • modify swift/kotlin code to pass in stub value for installation_date, then address the actual values on another PR

components/nimbus/src/lib.rs Outdated Show resolved Hide resolved
components/nimbus/src/lib.rs Show resolved Hide resolved
components/nimbus/Cargo.toml Show resolved Hide resolved
components/nimbus/src/lib.rs Outdated Show resolved Hide resolved
components/nimbus/src/lib.rs Outdated Show resolved Hide resolved
@@ -207,17 +220,43 @@ impl NimbusClient {

pub fn apply_pending_experiments(&self) -> Result<Vec<EnrollmentChangeEvent>> {
log::info!("updating experiment list");
// If the application did not pass in an installation date,
Copy link
Member Author

Choose a reason for hiding this comment

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

Added this logic here because it happens off the main thread... Not sure if it's the best place for it

@codecov-commenter
Copy link

codecov-commenter commented Sep 22, 2021

Codecov Report

❗ No coverage uploaded for pull request base (nimbus-targeting-object@f739139). Click here to learn what that means.
The diff coverage is 87.71%.

❗ Current head c678953 differs from pull request most recent head 3e7469e. Consider uploading reports for the commit 3e7469e to get more accurate results
Impacted file tree graph

@@                    Coverage Diff                     @@
##             nimbus-targeting-object    #4491   +/-   ##
==========================================================
  Coverage                           ?   76.71%           
==========================================================
  Files                              ?       48           
  Lines                              ?     4496           
  Branches                           ?        0           
==========================================================
  Hits                               ?     3449           
  Misses                             ?     1047           
  Partials                           ?        0           
Impacted Files Coverage Δ
components/nimbus/src/error.rs 11.76% <0.00%> (ø)
components/nimbus/src/persistence.rs 95.12% <ø> (ø)
components/nimbus/src/lib.rs 72.04% <82.73%> (ø)
components/nimbus/src/enrollment.rs 96.66% <97.61%> (ø)
components/nimbus/src/evaluator.rs 98.33% <100.00%> (ø)
...nts/nimbus/tests/test_time_targeting_attributes.rs 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f739139...3e7469e. Read the comment docs.

@tarikeshaq
Copy link
Member Author

Copy link
Contributor

@jhugman jhugman left a comment

Choose a reason for hiding this comment

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

Main changes needed:

  • make AppContext immutable again.
  • make a new struct with app_directory_path: string and days_since_install: i32? and pass it in as part of a Nimbus constructor.
  • calculate install_date and last_update_date and store them in the database.
  • calculate days_since_update and days_since_install from the stored dates and now().
  • Add a TimeBasedAttributes to TargetingAttributes with the days_since_update and days_since_install.

components/nimbus/src/lib.rs Outdated Show resolved Hide resolved
components/nimbus/src/lib.rs Outdated Show resolved Hide resolved
components/nimbus/Cargo.toml Show resolved Hide resolved
components/nimbus/src/lib.rs Show resolved Hide resolved
components/nimbus/src/lib.rs Outdated Show resolved Hide resolved
@tarikeshaq tarikeshaq changed the base branch from main to nimbus-targeting-object September 28, 2021 05:29
@tarikeshaq tarikeshaq marked this pull request as ready for review September 28, 2021 19:00
@tarikeshaq
Copy link
Member Author

Added tests, not 100% happy with how they look, but they test both the targeting and the fallback (it doesn't test that the actual fallback works, but it tests that we end up doing the fallback when we need to) I'll do a second go through the tests to see if I can make them better or cover more logic, but opening this up for more reviews!

Copy link
Contributor

@jhugman jhugman left a comment

Choose a reason for hiding this comment

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

This is looking lovely. There are a few bits I was confused about which you should address/answer/comment, but I don't think I should hold you up in another review cycle.

Good job!

components/nimbus/src/lib.rs Outdated Show resolved Hide resolved
components/nimbus/src/lib.rs Outdated Show resolved Hide resolved
components/nimbus/src/lib.rs Show resolved Hide resolved
@tarikeshaq tarikeshaq force-pushed the adds-install-date-nimbus branch 6 times, most recently from 90ef6b4 to a3120c2 Compare September 29, 2021 20:48
components/nimbus/src/lib.rs Outdated Show resolved Hide resolved
components/nimbus/src/nimbus.udl Show resolved Hide resolved
components/nimbus/src/matcher.rs Show resolved Hide resolved
components/nimbus/src/lib.rs Outdated Show resolved Hide resolved
Base automatically changed from nimbus-targeting-object to main September 30, 2021 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants