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

fix: usage and analytics data duplicates the current day #4529

Merged
merged 1 commit into from
Aug 21, 2024

Conversation

matthewelwell
Copy link
Contributor

@matthewelwell matthewelwell commented Aug 21, 2024

Changes

This code fixes an issue where the current day was duplicated in the usage / analytics graphs and all other days seemed to be off by one.

The reason for this was that the influx query was using the end of the aggregation window to use as the key for the data. This PR updates all uses of aggregateWindow in the code to use the start of the window as the key.

Note that this will mean that we get e.g. 91 results when asking for the last 90 days because it's essentially requesting the exact last (90 x 24h), so it will include today and the same chunk of the first day in the period. Without overcomplicating the query in Influx this would be difficult to solve and I think is perfectly acceptable for now.

Reference: https://docs.influxdata.com/flux/v0/stdlib/universe/aggregatewindow/#timesrc

How did you test this code?

I have updated the (mocked) tests, but obviously this isn't very useful.

@zachaysan and I ran the code against influx directly from my laptop and verified that the data was correct.

@matthewelwell matthewelwell requested a review from a team as a code owner August 21, 2024 16:50
@matthewelwell matthewelwell requested review from khvn26 and removed request for a team August 21, 2024 16:50
Copy link

vercel bot commented Aug 21, 2024

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

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs ⬜️ Ignored (Inspect) Aug 21, 2024 4:50pm
flagsmith-frontend-preview ⬜️ Ignored (Inspect) Aug 21, 2024 4:50pm
flagsmith-frontend-staging ⬜️ Ignored (Inspect) Aug 21, 2024 4:50pm

@github-actions github-actions bot added api Issue related to the REST API fix labels Aug 21, 2024
Copy link
Contributor

github-actions bot commented Aug 21, 2024

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-e2e:pr-4529 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-api-test:pr-4529 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-frontend:pr-4529 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-api:pr-4529 Finished ✅ Results
ghcr.io/flagsmith/flagsmith:pr-4529 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-private-cloud:pr-4529 Finished ✅ Results

Copy link
Contributor

github-actions bot commented Aug 21, 2024

Uffizzi Preview deployment-55437 was deleted.

Copy link
Member

@khvn26 khvn26 left a comment

Choose a reason for hiding this comment

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

LGTM apart from a couple of noop changes (whitespace?)

Copy link

codecov bot commented Aug 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.92%. Comparing base (18ed5d2) to head (fdde160).
Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4529   +/-   ##
=======================================
  Coverage   96.92%   96.92%           
=======================================
  Files        1178     1178           
  Lines       39623    39623           
=======================================
  Hits        38405    38405           
  Misses       1218     1218           

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

@matthewelwell matthewelwell added this pull request to the merge queue Aug 21, 2024
Merged via the queue into main with commit 910b3ed Aug 21, 2024
35 checks passed
@matthewelwell matthewelwell deleted the fix/influx-aggregation-shows-duplicate-days branch August 21, 2024 17:02
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 fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants