Average block time: live refresh via stats API refetch interval ENV#3461
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. To trigger a review, include ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
There was a problem hiding this comment.
Pull request overview
Adds optional, ENV-configured polling for selected Stats API resources so “average block time” and related homepage / /stats counters can refresh while the user stays on the page, without treating background refetch failures as full-page errors.
Changes:
- Introduces
NEXT_PUBLIC_STATS_API_REFETCH_INTERVAL(JSON map) and wires it into Stats API config parsing. - Adds
refetchIntervalto homepage stats widgets/charts and/statscounters queries, and adjusts error handling to ignore refetch-only errors. - Extends env validator + test env base values and documents the new variable.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/ENVS.md | Documents the new NEXT_PUBLIC_STATS_API_REFETCH_INTERVAL env var. |
| deploy/tools/envs-validator/test/.env.base | Adds a sample value for the new env var in validator tests. |
| deploy/tools/envs-validator/schemas/apis.ts | Adds yup validation for the new env var and dependency on NEXT_PUBLIC_STATS_API_HOST. |
| configs/app/apis.ts | Parses env JSON map and exposes stats.refetchInterval in app config. |
| client/slices/home/pages/index/stats/Stats.tsx | Adds polling for stats:pages_main and avoids degrading UI on refetch-only errors. |
| client/slices/home/pages/index/charts/ChainIndicators.tsx | Adds polling for stats:pages_main indicators. |
| client/slices/home/hooks/useChartDataQuery.ts | Adds polling for stats:pages_main chart queries and refetch-error handling. |
| client/features/chain-stats/types/config.ts | Defines the allowed Stats API resources that can be configured for polling. |
| client/features/chain-stats/pages/index/ChainStatsCounters.tsx | Adds polling for stats:counters and ignores refetch-only errors for alert display. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Description and Related Issue(s)
Resolves #3407
Adds optional polling for Stats API resources so average block time (and related homepage stats) update while the user stays on the page, on both the main page and
/stats.Proposed Changes
NEXT_PUBLIC_STATS_API_REFETCH_INTERVAL— a JSON map of Stats API resource names to refetch intervals in milliseconds.refetchIntervalinto:stats:pages_mainon the homepage (Stats,ChainIndicators, chart queries)stats:counterson the chain stats page (ChainStatsCounters)NEXT_PUBLIC_STATS_API_HOSTwhen set) and document the variable inENVS.md.Environment variable changes
NEXT_PUBLIC_STATS_API_REFETCH_INTERVALstats:counters(chain stats counters, including average block time on/stats) andstats:pages_main(homepage stats widgets and charts, including average block time on the main page). Example:{'stats:pages_main': 10000, 'stats:counters': 10000}. Only valid whenNEXT_PUBLIC_STATS_API_HOSTis configured.Breaking or Incompatible Changes
None. The variable is optional; without it, behavior is unchanged (no polling).
Additional Information
Checklist for PR author