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

feat(analytics): Command to populate arbitrary periods of analytics data #4155

Merged
merged 3 commits into from
Jun 13, 2024

Conversation

khvn26
Copy link
Member

@khvn26 khvn26 commented Jun 12, 2024

Thanks for submitting a PR! Please check the boxes below:

  • I have run pre-commit to check linting
  • I have added information to docs/ if required so people know about the feature!
  • I have filled in the "Changes" section below?
  • I have filled in the "How did you test this code" section below?
  • I have used a Conventional Commit title for this Pull Request

Changes

  1. Bucket population is now idempotent; existing buckets get overwritten.
  2. A management command is added to (re-)populate arbitrary periods.

How did you test this code?

Added unit tests to verify upserts, and to verify the management command.

@khvn26 khvn26 requested review from a team and matthewelwell and removed request for a team June 12, 2024 17:28
Copy link

vercel bot commented Jun 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Ignored Deployments
Name Status Preview Comments Updated (UTC)
docs ⬜️ Ignored (Inspect) Visit Preview Jun 13, 2024 0:18am
flagsmith-frontend-preview ⬜️ Ignored (Inspect) Visit Preview Jun 13, 2024 0:18am
flagsmith-frontend-staging ⬜️ Ignored (Inspect) Visit Preview Jun 13, 2024 0:18am

@github-actions github-actions bot added api Issue related to the REST API feature New feature or request labels Jun 12, 2024
Copy link
Contributor

github-actions bot commented Jun 12, 2024

Uffizzi Preview deployment-52968 was deleted.

Copy link

codecov bot commented Jun 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.50%. Comparing base (baf8ddb) to head (2dff930).
Report is 7 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4155   +/-   ##
=======================================
  Coverage   96.49%   96.50%           
=======================================
  Files        1175     1177    +2     
  Lines       38124    38191   +67     
=======================================
+ Hits        36789    36856   +67     
  Misses       1335     1335           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -278,6 +278,74 @@ def test_populate_feature_evaluation_bucket_15m(freezer):
assert buckets[7].total_count == 15


@pytest.mark.freeze_time("2023-01-19T09:00:00+00:00")
@pytest.mark.django_db(databases=["analytics"])
def test_populate_feature_evaluation_bucket__upserts_buckets(freezer) -> None:
Copy link
Member Author

Choose a reason for hiding this comment

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

freezegun upgrade is blocked by restframework/django 4 upgrade, hence no type annotation here.

Copy link
Contributor

@matthewelwell matthewelwell left a comment

Choose a reason for hiding this comment

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

Approved with a minor typing comment

@@ -278,6 +278,74 @@ def test_populate_feature_evaluation_bucket_15m(freezer):
assert buckets[7].total_count == 15


@pytest.mark.freeze_time("2023-01-19T09:00:00+00:00")
@pytest.mark.django_db(databases=["analytics"])
def test_populate_feature_evaluation_bucket__upserts_buckets(freezer) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm... I wanted to add a comment here to add typing for the freezer argument, but it looks as though it's type is perhaps Union[StepTickTimeFactory, TickingDateTimeFactory, FrozenDateTimeFactory] (based on this and this) although, since we're not passing either of the tick or auto_tick_seconds arguments, I think the type is actually FrozenDateTimeFactory, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Didn't realize this version of freezegun exports the type. Thanks! Updated annotations across the whole module.

@github-actions github-actions bot added feature New feature or request and removed feature New feature or request labels Jun 13, 2024
@khvn26 khvn26 requested a review from matthewelwell June 13, 2024 12:19
@matthewelwell matthewelwell changed the title feat(analytics): Command to populate arbitraty periods of analytics data feat(analytics): Command to populate arbitrary periods of analytics data Jun 13, 2024
@khvn26 khvn26 added this pull request to the merge queue Jun 13, 2024
Merged via the queue into main with commit 20fb43e Jun 13, 2024
22 checks passed
@khvn26 khvn26 deleted the feat/analytics-populate-arbitrary-periods branch June 13, 2024 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issue related to the REST API feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants