Open
Conversation
## Changes - Add GET /monitors/uptime/stats/:monitorId endpoint - Single MongoDB $facet aggregation computes uptime % for all periods (24h, 7d, 30d, 1y, all) in one query - Add UptimeStatsByPeriod component displayed between stat boxes and time range selector on monitor detail page - Color-coded percentages: green (>=99%), yellow (>=95%), red (<95%) - Fix z.email() -> z.string().email() in shared validation (Zod compatibility)
## Changes - Replace $facet with single $group using conditional sums for better efficiency (single scan instead of 5x) - Move getColor to MonitorUtils.ts as getUptimeColor for reuse - Add refreshInterval to SWR call to prevent stale data - Fix remaining z.email() calls to z.string().email() across validation files ## Benefits - Aggregation now scans documents once instead of five times - Reduced memory usage for monitors with large check histories - Consistent color utility location alongside other threshold functions
Remove the dedicated /monitors/uptime/stats/:monitorId endpoint and its aggregation pipeline. Instead, reuse the existing details endpoint by fetching /monitors/uptime/details/:monitorId for each of the 4 time ranges (2h, 24h, 7d, 30d) and displaying the uptimePercentage from each response. This avoids adding a new expensive aggregation that scans all checks and instead leverages the existing time-scoped pipeline.
- Use StatBox component for uptime period cards (fixes unused 'periods' error in previous push) - Fix prettier formatting in authValidation.ts
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.
Summary
Closes #3364
UptimeStatsByPeriodcomponent on the uptime details page showing uptime percentages for 4 periods (2h, 24h, 7d, 30d)/monitors/uptime/details/:monitorIdendpoint — no new aggregation pipeline addedz.email()→z.string().email()Zod compatibility issue across all validation filesTest plan