Repository navigation
Isha aking over for Kanishk: Add Event Popularity Analytics API Endpoints - #1941
Conversation
93557cd to
65f983b
Compare
65f983b to
15bdfec
Compare
|
iAbhi001
left a comment
There was a problem hiding this comment.
Here is a clear, professional review comment you can post directly on the GitHub PR:
Hi @rithika-paii,
I reviewed and tested your PR locally, but I encountered a few issues while testing:
- 404 API Endpoint Errors:
- On the reports page, the top analytics cards fail to load data, throwing
Error: Request failed with status code 404. - Please verify that the backend API routes (
/api/events/popularity,/api/events/engagement,/api/events/value,/api/events/format-comparison) are properly registered and reachable.
- Broken Navigation ("Page Not Found"):
- Clicking on Details (or navigating from event cards) redirects to a
PAGE NOT FOUNDerror screen (404). Please double-check the route mapping/URLs defined for event details.
Could you please look into these routing and API endpoint issues?
sawantgayatri19
left a comment
There was a problem hiding this comment.
Hi @rithika-paii,
I reviewed and tested your PR locally, but I encountered a few routing and API issues that need to be resolved:
-
404 API Endpoint Errors:
- On the reports page, the top analytics cards fail to load data, throwing
Error: Request failed with status code 404. - Please verify that the backend API routes (
/api/events/popularity,/api/events/engagement,/api/events/value,/api/events/format-comparison) are properly registered insrc/startup/routes.jsand reachable.
- On the reports page, the top analytics cards fail to load data, throwing
-
Broken Navigation ("Page Not Found"):
- Clicking on Details (or navigating from event cards) redirects to a (PAGE NOT FOUND) error screen (
404). Please double-check the route mapping and URLs defined for event details.
- Clicking on Details (or navigating from event cards) redirects to a (PAGE NOT FOUND) error screen (
Could you please look into these routing and API endpoint issues so we can proceed with merging?
AdiDubbs
left a comment
There was a problem hiding this comment.
The controller structure is clear, and the added test suite passes locally.
The date handling needs a fix before merge: a date-only endDate becomes UTC midnight, so $lte excludes events later that same day. Invalid or reversed ranges are also not rejected. All four endpoints use the same pattern, so a shared helper and boundary tests would keep the metrics consistent.
| if (startDate || endDate) { | ||
| query.date = {}; | ||
| if (startDate) query.date.$gte = new Date(startDate); | ||
| if (endDate) query.date.$lte = new Date(endDate); |
There was a problem hiding this comment.
new Date('2026-08-08') is UTC midnight, so $lte excludes every event later on August 8. A request for August 1–8 therefore omits data from the end date itself.
All four endpoints repeat this pattern, and invalid or reversed ranges are not rejected. injuryCategoryController.js already handles date-only bounds by advancing the end date and using $lt, while returning a 400 for invalid dates. A shared helper plus a boundary test would keep these endpoints consistent.
- Created eventPopularityController with metrics calculation functions - Implemented getPopularityMetrics endpoint for event type breakdown - Implemented getEngagementMetrics endpoint for session analytics - Implemented getEventValue endpoint for estimated value calculations - Implemented getFormatComparison endpoint for Virtual vs In-Person comparison - Created eventPopularityRouter with all API routes - Registered router in startup/routes.js - Added proper error handling and logging - All endpoints support date range filtering via query parameters
…range filtering on event popularity endpoints
abe38bf to
5a0ae1e
Compare
|
vidiyala99
left a comment
There was a problem hiding this comment.
Tested the new head 56ce0f0 on a test server against the shared dev data (207 events), calling the four endpoints directly as Administrator (read-only). The controller tests pass (eventPopularityController.test.js, 20/20).
Earlier review items:
- Routes:
GET /api/events/popularity,/events/engagement,/events/valueand/events/format-comparisonall return 200 with data now (the 404 and 500 responses reported in August are gone). - Date-only
endDate: fixed.startDate=2026-10-08&endDate=2026-10-08returns the 3 events stored as2026-10-08T07:00:00Z, and2026-10-01to2026-10-08returns exactly the 11 events in that range, so events later on the end day are included. - Invalid dates:
startDate=notadatereturns400 "Invalid startDate or endDate (use YYYY-MM-DD or ISO)". - Consistency: total attendees agree between popularity (sum of the per-type
totalAttendees) and engagement: both 190, which matches the events'currentAttendees.
Notes, not blocking:
- Format comparison silently drops events with no location. Dev has 179 "Virtual" and 24 "In person" events, plus 4 with a blank location (
""three times," "once).format-comparisonreturns virtual 179 events / 95 attendees and in-person 24 / 49, so those 4 events and 46 attendees disappear, and its totals no longer match the other endpoints (207 events, 190 attendees). An "unspecified" bucket (after trimming) would keep the numbers consistent. - A reversed range isn't rejected:
startDate=2026-12-31&endDate=2020-01-01returns200 {"metrics":[]}. Returning 400 like the invalid-date case would make a swapped date picker easier to spot.
Approving.
|
Thank you all, merging! |
Fixed









Description
This PR adds backend API endpoints for Event Popularity Analytics. Please verify everything shows properly in the frontend PR.
Related PRs
Main Changes
New Controller
getPopularityMetrics()- Calculates popularity metrics by event typegetEngagementMetrics()- Calculates engagement metrics (session duration, interaction rate)getEventValue()- Calculates estimated value per eventgetFormatComparison()- Compares Virtual vs In-Person event metricsNew Router
GET /api/events/popularity- Get popularity metricsGET /api/events/engagement- Get engagement metricsGET /api/events/value- Get event value calculationsGET /api/events/format-comparison- Get format comparison dataRoute Registration
src/startup/routes.jsto register the new eventPopularityRouterReviewer Notes