-
Notifications
You must be signed in to change notification settings - Fork 9
Offline Caching #4902
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Offline Caching #4902
Conversation
Storage tests Allow showing cached data when starting app while offline
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #4902 +/- ##
==========================================
+ Coverage 70.89% 71.09% +0.20%
==========================================
Files 372 442 +70
Lines 15577 17251 +1674
Branches 1840 2168 +328
==========================================
+ Hits 11043 12265 +1222
- Misses 3930 4337 +407
- Partials 604 649 +45 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
conbrad
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking really good! Just a few thoughts to consider
brettedw
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was an absolute beast, great job!!
| export const readFromFilesystem = async ( | ||
| filesystem: FilesystemPlugin, | ||
| key: string | ||
| ) => { | ||
| try { | ||
| const result = await filesystem.readFile({ | ||
| path: getPath(key), | ||
| directory: Directory.Data, | ||
| encoding: Encoding.UTF8, | ||
| }); | ||
| return JSON.parse(result.data as string); | ||
| } catch { | ||
| return null; | ||
| } | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if functions like this could benefit from generics in their return typing, so the return type isn't any. Not sure if you think it's worth it or not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|

I moved the logic for the 'start date' of the app from
App.tsxtodataSliceUtils.tswhich will facilitate testing with dates in the past. ie. To load historical data in the app settoday = Datetime.fromISO("2025-7-11")indataSliceUtils.ts.If you have your
.envfile setup to use your dev API instance you can either monitor logs or set breakpoints in thefba.pyrouter module to ensure that API requests are made as per the criteria listed below.Data cached with a 12 hour TTL:
Data we cache for the entire province for TDY and TMR:
Expected behaviour while online:
First time launching the app:
Toggling TDY - TMR should trigger a request for SFMS run parameters every time while online. If we have cached fire shape area, fire shape area detail, hfi and tpi data associated with the most recent run parameters, no api request is made for these data. If cached fire shape area, fire shape area detail, hfi and tpi data are stale we re-fetch from the API, cache the latest values and update redux state.
Subsequent app launches:
Expected behaviour after transitioning from online to offline:
Expected behaviour after transitioning from offline to online:
runParametersExpected behaviour when launching while offline:
Expected behaviour when offline overnight:
There is nothing in the UI yet to indicate that data is stale or that we're offline.
Closes: #4741
Test Links:
Landing Page
MoreCast
Percentile Calculator
C-Haines
FireCalc
FireCalc bookmark
Auto Spatial Advisory (ASA)
HFI Calculator
SFMS Insights
Fire Watch