Repository navigation
feat(stats): add /v2/stats/means-peak for peak operatives and means (#30) - #50
Merged
Merged
Conversation
) For the incidents that started in [after, before] (optionally filtered by district/concelho/freguesia), returns the highest man, terrain and aerial values recorded in the incident history, with the time each peak was recorded and the incident. Uses raw queries so legacy documents (ObjectId _id plus a separate `id` field) are matched; laravel-mongodb v5 aliases `id` to `_id`. Interval limited to 366 days, response cached for 1 hour. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 71a6f40d95
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
) IncidentResource adds history/statusHistory when the current request has `extend`, and the cache key ignores it, so an extend=1 request could populate the shared 1h entry with the full collections (and vice versa). Resolve the incident against an empty request for a fixed shape. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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 #30
What
GET /v2/stats/means-peak?after=YYYY-MM-DD&before=YYYY-MM-DD[&district=][&concelho=][&freguesia=][&all=1]As clarified in the issue thread: for each kind of means, the peak reached by a single incident, with the incident and the time it happened.
{ "success": true, "data": { "incidents": 412, "man": { "value": 60, "at": "2025-08-10T16:00:00+01:00", "incident": { …IncidentResource… } }, "terrain": { "value": 14, "at": "…", "incident": { … } }, "aerial": { "value": 12, "at": "2025-08-20T13:15:00+01:00", "incident": { … } } } }Semantics
dateTime) betweenafter00:00 andbefore23:59:59, Europe/Lisbon. Fires only, unlessall=1.historysnapshots of those incidents (saved on every change of man/terrain/aerial). Earliest snapshot wins on ties.at= when that snapshot was recorded.-1) are ignored. No history →null.nulls.before < after, or an interval > 366 days. Response cached 1h in Redis.Implementation notes
id→_id, but legacy documents keep the business id in a separateidfield and their history references it viaid. Covered by a test.historyindexes (incidentId/id+created).Tests
tests/Feature/Controllers/StatsController/MeansPeakTest.php(5 tests: validation, peaks + time + incident, interval boundaries, location filter, string values/nulls, legacy documents). Full suite against a throwaway MongoDB 7: 85 pass.OpenAPI:
docs/stats/paths/v2-stats-means-peak.yaml+docs/stats/models/MeansPeak.yaml, referenced fromdocs/api.yaml.Deploy
Deploy as usual. No env changes, no migrations, no queue restart needed.
🤖 Generated with Claude Code