-
-
Notifications
You must be signed in to change notification settings - Fork 8
Add data util method to allow adding locally stored data #584
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: develop
Are you sure you want to change the base?
Changes from all commits
2373f62
0ec041c
17e3e6d
85121a8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -109,6 +109,33 @@ export class DataUtil { | |||||
| this.endTimer('init total'); | ||||||
| }; | ||||||
|
|
||||||
| addLocalData = (patientId, returnData = false, localDataSource) => { | ||||||
|
||||||
| let data; | ||||||
| try { | ||||||
| // eslint-disable-next-line global-require, import/no-unresolved | ||||||
| data = require('../../local/rawData.json'); | ||||||
| let dataSource = localDataSource === 'export' ? 'the Tidepool export service' : 'the Tidepool API'; | ||||||
|
||||||
|
|
||||||
| if (data?.data?.current?.data) { | ||||||
| data = _.flatten(_.values(data.data.current.data)); | ||||||
| dataSource = 'a Tidepool Web console export'; | ||||||
| } else if (data?.[0].dataset) { | ||||||
| data = _.flatten(_.map(data, v => v.data)); | ||||||
| dataSource = 'a Tidepool Account Tool export'; | ||||||
| } | ||||||
|
|
||||||
| this.log(`Loading dataset provided by ${dataSource}`); | ||||||
| } catch (e) { | ||||||
| data = { data: [] }; | ||||||
|
||||||
| data = { data: [] }; | |
| data = []; |
Copilot
AI
Jan 22, 2026
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.
The new addLocalData method lacks test coverage. The repository has comprehensive tests for DataUtil (as seen in test/utils/DataUtil.test.js with 6454 lines), and other methods like addData are thoroughly tested. This new method should have corresponding test cases covering different scenarios: successful data loading from different formats (Tidepool Web console export, Tidepool Account Tool export, direct API format), error handling when the file doesn't exist, and the export format duration conversion logic.
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.
The new
addLocalDatamethod lacks JSDoc documentation. Given that other methods in the DataUtil class have JSDoc comments (as seen in the constructor), this method should include documentation explaining its parameters (especially thelocalDataSourceparameter which has specific behavior), return value, and purpose. This is particularly important since this is a new public API.