fix: ignore stale weather data - #124
Conversation
📝 WalkthroughWalkthroughCurrent weather, air-quality, and allergen documents now use explicit observation times for two-hour freshness filtering. Stale current data is excluded, while forecasts, dated forecast requests, and valid alerts follow separate rules. Documentation and tests define and verify these behaviors. ChangesDocument freshness handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant ProviderSet
participant collect_weather_documents
participant SnapshotTimeResolver
participant StaleCurrentFilter
ProviderSet->>collect_weather_documents: provide WeatherContextSnapshot values
collect_weather_documents->>SnapshotTimeResolver: attach observation times to documents
SnapshotTimeResolver-->>collect_weather_documents: return timed SourceDocument values
collect_weather_documents->>StaleCurrentFilter: filter current documents within two hours
StaleCurrentFilter-->>collect_weather_documents: return eligible documents
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #124 +/- ##
=======================================
Coverage 99.86% 99.86%
=======================================
Files 116 117 +1
Lines 12345 12435 +90
Branches 737 742 +5
=======================================
+ Hits 12328 12418 +90
Misses 12 12
Partials 5 5 ☔ View full report in Codecov by Harness. |
|
/agentic_review |
Code Review by Qodo
1.
|
|
ⓘ Your Qodo trial ends soon. Ask your workspace admin to set up billing to keep reviews running after the trial. Manage billing |
PR Summary by QodoIgnore stale current observations beyond 2-hour freshness window
AI Description
Diagram
High-Level Assessment
Files changed (7)
|
|
Code review by qodo was updated up to the latest commit 0cb8a79 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/requirements.md`:
- Line 56: Update the current-air-quality observation requirement in
docs/requirements.md to define “时刻接近” precisely: exclude observations more than
two hours older than the newest observation, while retaining observations
exactly two hours older. Keep the wording focused on user-visible product
behavior without adding implementation details.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: fa4fbc98-278f-4526-9c62-4895b30c0d7d
📒 Files selected for processing (6)
README.mddocs/design.mddocs/notes.mddocs/requirements.mdtests/test_collection.pyweather_briefing/application/collection.py
|
/agentic_review |
|
Code review by qodo was updated up to the latest commit 9c0ea27 |
|
Code review by qodo was updated up to the latest commit 9c0ea27 |
|
/agentic_review |
|
Code review by qodo was updated up to the latest commit 2917a25 |
|
/agentic_review |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@weather_briefing/application/collection.py`:
- Around line 118-135: In weather_briefing/application/collection.py lines
118-135, update the air-quality and allergen handling in the snapshot collection
flow to remove the weather_observed_at fallback and exclude or reject current
sub-documents whose own observation timestamp is missing, while preserving
independently timestamped observations. In docs/design.md line 138, document
that air-quality and allergen freshness never falls back to the weather
snapshot. In tests/test_collection.py lines 188-201, replace the allergen
fallback expectation with exclusion of an allergen lacking observed_at and add
the equivalent exclusion case for air quality.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: ad985fa1-eb36-4799-ae32-cb02d2a0521f
📒 Files selected for processing (7)
README.mddocs/design.mddocs/requirements.mdtests/test_collection.pytests/test_prompts.pyweather_briefing/application/collection.pyweather_briefing/data/system_prompt.txt
🚧 Files skipped from review as they are similar to previous changes (1)
- README.md
|
Code review by qodo was updated up to the latest commit 0fa6ed7 |
|
Qodo finding 3 reviewed; not adopting it. The |
Understood. |
Summary
Root cause
Freshness was enforced only for air-quality documents. Other stale current fields could remain in the briefing, and deferred short-lived information relied on a less precise recency instruction.
User impact
Briefings no longer treat source data from many hours earlier as current, whether it arrives in the current collection or remains in deferred history. Active warnings, disaster tracking, and dated forecasts continue to use their own validity rules.