Skip to content

ASA Go: Cache provincial-summary, hfi-stats, and tpi-stats in Redis - #5795

Merged
conbrad merged 6 commits into
mainfrom
task/asago-api-cache
Sep 2, 2026
Merged

ASA Go: Cache provincial-summary, hfi-stats, and tpi-stats in Redis#5795
conbrad merged 6 commits into
mainfrom
task/asago-api-cache

Conversation

@conbrad

@conbrad conbrad commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

During the same load test that led to #5780, provincial-summary, hfi-stats, and tpi-stats which are 7 of the 9-10 requests ASA Go's makes on every launch hits Postgres directly on every single call. All three are read-heavy and keyed to a specific completed SFMS run (run_type/run_datetime/for_date) that never changes once that run finishes, making them ideal candidates to cache rather than re-query.

Results are now cached in Redis (app/auto_spatial_advisory/advisory_run_stats/), keyed on the run identity so a new run naturally gets a new key with no invalidation needed, with a 1-day TTL — following the same pattern hfi/fire_centre_cache.py already uses elsewhere in the API. The Redis client is built with explicit 1s connect/socket timeouts rather than the shared create_redis() helper's untimed default, so an unreachable Redis fails fast into the existing Postgres path instead of hanging the request's event loop. latest-sfms-run-parameters deliberately stays uncached, since it's the "what's newest" endpoint and caching it would risk serving a stale answer right after a new run finishes.

Test Links:

Landing Page
MoreCast
Percentile Calculator
FireCalc
FireCalc bookmark
Auto Spatial Advisory (ASA)
HFI Calculator
SFMS Insights
Fire Watch
Weather Toolkit

@codecov

codecov Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.46237% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 68.90%. Comparing base (89c4d57) to head (aadd400).

Files with missing lines Patch % Lines
.../auto_spatial_advisory/advisory_run_stats/stats.py 99.09% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5795      +/-   ##
==========================================
+ Coverage   68.71%   68.90%   +0.18%     
==========================================
  Files         385      388       +3     
  Lines       21558    21660     +102     
  Branches     2935     2937       +2     
==========================================
+ Hits        14813    14924     +111     
+ Misses       5837     5830       -7     
+ Partials      908      906       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sonarqubecloud

sonarqubecloud Bot commented Sep 2, 2026

Copy link
Copy Markdown

@conbrad
conbrad deployed to production September 2, 2026 21:40 Active
@conbrad
conbrad merged commit 0af9b09 into main Sep 2, 2026
38 checks passed
@conbrad
conbrad deleted the task/asago-api-cache branch September 2, 2026 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant