feat(analytics): add date range filtering to analytics endpoints usin… - #868
Open
jikrana1 wants to merge 1 commit into
Open
feat(analytics): add date range filtering to analytics endpoints usin…#868jikrana1 wants to merge 1 commit into
jikrana1 wants to merge 1 commit into
Conversation
…g query params (Closes Userunknown84#854)
|
Someone is attempting to deploy a commit to the Aditya Sharma's projects Team on Vercel. A member of the Team first needs to authorize it. |
Userunknown84
requested changes
Jul 14, 2026
Userunknown84
left a comment
Owner
There was a problem hiding this comment.
Merge Conflict shown kindly fix this
Userunknown84
approved these changes
Jul 15, 2026
Userunknown84
requested changes
Jul 15, 2026
Userunknown84
left a comment
Owner
There was a problem hiding this comment.
Merge conflict shown kindly fix this.
| const counts = await History.aggregate([ | ||
| { | ||
| $match: { | ||
| user: userId, |
Owner
There was a problem hiding this comment.
Ye part delete h sabhi parts me
Owner
|
@jikrana1 fix the issue then i will merge. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #854
Problem description
The analytics endpoints currently process the user's complete history without allowing any date filtering. As the amount of stored history grows, analytics queries become slower and users cannot generate reports for specific periods such as the last 7 days, last 30 days, 90 days, or a custom date range.
Proposed solution
Added optional query parameter support (
from,to,last) to thegetSummary,getTrends,getBreakdown, andgetPersonalSummaryendpoints.Implementation details:
buildDateFilterhelper function to parse and validatefrom,to, andlast.from/tomust be valid dates,lastmust be a positive integer.400 Bad Requestwith descriptive error messages for invalid combinations.$matchstage of all 4 aggregation pipelines, ensuringcreatedAtis filtered efficiently before any grouping occurs.Benefits
Testing instructions
/analytics/summary?last=7. It should return stats for the last 7 days./analytics/summary?from=2026-01-01&to=2026-06-30. It should return stats for that specific 6-month range./analytics/summary?last=7&from=2026-01-01. It should return a400 Bad Requesterror (cannot combinelastwithfrom/to).