Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/pages/patientdata/patientdata.js
Original file line number Diff line number Diff line change
Expand Up @@ -2569,6 +2569,7 @@ let mergeProps = (stateProps, dispatchProps, ownProps) => {
const dexcom = utils.getDexcom(ownProps.location);
const medtronic = utils.getMedtronic(ownProps.location);
const cbgFilter = utils.getCBGFilter(ownProps.location);
const localDataSource = ownProps.location.query.localDataSource;

Copilot AI Jan 22, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The localDataSource parameter is extracted from the query string but not validated or type-checked. Query parameters are always strings, so if the parameter is present (even as an empty string like "localDataSource="), it will be truthy and trigger the local data path. Consider converting it to a boolean or checking for specific truthy values to avoid unintended behavior.

Suggested change
const localDataSource = ownProps.location.query.localDataSource;
const localDataSourceParam = ownProps.location.query.localDataSource;
const localDataSource = localDataSourceParam === 'true' ||
localDataSourceParam === '1' ||
localDataSourceParam === 'yes';

Copilot uses AI. Check for mistakes.
const api = ownProps.api;
const assignedDispatchProps = [
'dataWorkerRemoveDataRequest',
Expand All @@ -2582,7 +2583,7 @@ let mergeProps = (stateProps, dispatchProps, ownProps) => {
];

return Object.assign({}, _.pick(dispatchProps, assignedDispatchProps), stateProps, {
fetchers: getFetchers(dispatchProps, ownProps, stateProps, api, { carelink, dexcom, medtronic, cbgFilter }),
fetchers: getFetchers(dispatchProps, ownProps, stateProps, api, { carelink, dexcom, medtronic, cbgFilter, localDataSource }),
history: ownProps.history,
location: ownProps.location,
match: ownProps.match,
Expand Down
3 changes: 2 additions & 1 deletion app/redux/actions/async.js
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,7 @@ export function fetchPatientData(api, options, id) {
// Default to only selecting the most recent 8 weeks of data
_.defaults(options, {
returnData: false,
localDataSource: false,
useCache: true,
initial: true,
type: ALL_FETCHED_DATA_TYPES.join(','),
Expand Down Expand Up @@ -1181,7 +1182,7 @@ export function fetchPatientData(api, options, id) {
(location.pathname.indexOf(id) >= 0 && (!fetchingPatientId || fetchingPatientId === id))
) {
if (options.sampleIntervalMinimum === MS_IN_MIN) options.oneMinCgmFetchedUntil = options.startDate;
dispatch(worker.dataWorkerAddDataRequest(data, options.returnData, patientId, options.startDate, options.oneMinCgmFetchedUntil));
dispatch(worker.dataWorkerAddDataRequest(data, options.returnData, patientId, options.startDate, options.oneMinCgmFetchedUntil, options.localDataSource));
}
}

Expand Down
3 changes: 2 additions & 1 deletion app/redux/actions/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export function removeGeneratedPDFS() {
}

/* Data Worker */
export function dataWorkerAddDataRequest(data = [], returnData, patientId, fetchedUntil, oneMinCgmFetchedUntil ) {
export function dataWorkerAddDataRequest(data = [], returnData, patientId, fetchedUntil, oneMinCgmFetchedUntil, localDataSource ) {

Copilot AI Jan 22, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a trailing space after the localDataSource parameter. This should be removed for consistency with the rest of the codebase.

Suggested change
export function dataWorkerAddDataRequest(data = [], returnData, patientId, fetchedUntil, oneMinCgmFetchedUntil, localDataSource ) {
export function dataWorkerAddDataRequest(data = [], returnData, patientId, fetchedUntil, oneMinCgmFetchedUntil, localDataSource) {

Copilot uses AI. Check for mistakes.
return {
type: actionTypes.DATA_WORKER_ADD_DATA_REQUEST,
meta: { WebWorker: true, worker: 'data', id: patientId },
Expand All @@ -64,6 +64,7 @@ export function dataWorkerAddDataRequest(data = [], returnData, patientId, fetch
oneMinCgmFetchedUntil,
patientId,
returnData,
localDataSource,
},
};
}
Expand Down
4 changes: 2 additions & 2 deletions app/worker/DataWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ export default class DataWorker {
case actionTypes.DATA_WORKER_ADD_DATA_REQUEST: {
try {
const data = JSON.parse(action.payload.data);
const { patientId, returnData } = action.payload;
const result = this.dataUtil.addData(data, patientId, returnData);
const { patientId, returnData, localDataSource } = action.payload;
const result = localDataSource ? this.dataUtil.addLocalData(patientId, returnData, localDataSource) : this.dataUtil.addData(data, patientId, returnData);
Comment on lines 40 to +42

Copilot AI Jan 22, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When localDataSource is truthy, the data variable (which is parsed from JSON on line 40) is not used. This results in unnecessary parsing overhead. Consider moving the JSON.parse call inside the conditional so it's only executed when needed, or alternatively, only parse the data when localDataSource is falsy.

Copilot uses AI. Check for mistakes.
postMessage(actions.dataWorkerAddDataSuccess(result));
} catch (error) {
postMessage(actions.dataWorkerAddDataFailure(error));
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"node": "20.8.0"
},
"packageManager": "yarn@3.6.4",
"version": "1.93.0-web-4272-change-bolus-filter-name-from-calculator-to-meal.1",
"version": "1.93.0-local-data-source.1",
"private": true,
"scripts": {
"test": "TZ=UTC NODE_ENV=test yarn jest --verbose --runInBand; JEST_EXIT_CODE=$?; TZ=UTC NODE_ENV=test NODE_OPTIONS='--max-old-space-size=4096' yarn karma start; KARMA_EXIT_CODE=$?; [ $JEST_EXIT_CODE -eq 0 ] && [ $KARMA_EXIT_CODE -eq 0 ]",
Expand Down Expand Up @@ -76,7 +76,7 @@
"@testing-library/react": "12.1.5",
"@testing-library/react-hooks": "8.0.1",
"@testing-library/user-event": "14.6.1",
"@tidepool/viz": "1.54.0-web-4274-copy-billing.6",
"@tidepool/viz": "1.54.0-local-data-source.1",
"async": "2.6.4",
"autoprefixer": "10.4.16",
"babel-core": "7.0.0-bridge.0",
Expand Down Expand Up @@ -198,7 +198,7 @@
"terser": "5.22.0",
"terser-webpack-plugin": "5.3.9",
"theme-ui": "0.16.1",
"tideline": "1.38.0-web-3886-basics-view-site-change-regression.1",
"tideline": "1.38.0-local-data-source.1",
"tidepool-platform-client": "0.64.0",
"tidepool-standard-action": "0.1.1",
"ua-parser-js": "1.0.36",
Expand Down
2 changes: 2 additions & 0 deletions test/unit/redux/actions/async.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4169,6 +4169,7 @@ describe('Actions', () => {
fetchedUntil: '2018-01-01T00:00:00.000Z',
oneMinCgmFetchedUntil: undefined,
returnData: false,
localDataSource: false,
},
},
];
Expand Down Expand Up @@ -4210,6 +4211,7 @@ describe('Actions', () => {
fetchedUntil: '2018-01-01T00:00:00.000Z',
oneMinCgmFetchedUntil: '2018-01-01T00:00:00.000Z',
returnData: false,
localDataSource: false,
},
},
];
Expand Down
1 change: 1 addition & 0 deletions test/unit/redux/actions/worker.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ describe('worker action creators', () => {
patientId,
fetchedUntil,
oneMinCgmFetchedUntil: undefined,
localDataSource: undefined,
},
});
});
Expand Down
20 changes: 10 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6083,9 +6083,9 @@ __metadata:
languageName: node
linkType: hard

"@tidepool/viz@npm:1.54.0-web-4274-copy-billing.6":
version: 1.54.0-web-4274-copy-billing.6
resolution: "@tidepool/viz@npm:1.54.0-web-4274-copy-billing.6"
"@tidepool/viz@npm:1.54.0-local-data-source.1":
version: 1.54.0-local-data-source.1
resolution: "@tidepool/viz@npm:1.54.0-local-data-source.1"
dependencies:
bluebird: 3.7.2
bows: 1.7.2
Expand Down Expand Up @@ -6146,7 +6146,7 @@ __metadata:
react-dom: 16.x
react-redux: 8.x
redux: 4.x
checksum: f80b2d6aefb7399772ce3084b7b1699737daa89b1f92ced5b01f40620dce72eb76b04f91e20f4285ba6e075630f0361c8adb952aec36dc7ba1888d491266eef6
checksum: ad383ef1c308bd0340cb1faebb582f4796f03b34d252916d5334e04be0ba2b01b6d78b108ac53a9cf41829d22fa2949f8ab04776cd6ebad1aa1f262e4166d7d9
languageName: node
linkType: hard

Expand Down Expand Up @@ -8335,7 +8335,7 @@ __metadata:
"@testing-library/react": 12.1.5
"@testing-library/react-hooks": 8.0.1
"@testing-library/user-event": 14.6.1
"@tidepool/viz": 1.54.0-web-4274-copy-billing.6
"@tidepool/viz": 1.54.0-local-data-source.1
async: 2.6.4
autoprefixer: 10.4.16
babel-core: 7.0.0-bridge.0
Expand Down Expand Up @@ -8464,7 +8464,7 @@ __metadata:
terser: 5.22.0
terser-webpack-plugin: 5.3.9
theme-ui: 0.16.1
tideline: 1.38.0-web-3886-basics-view-site-change-regression.1
tideline: 1.38.0-local-data-source.1
tidepool-platform-client: 0.64.0
tidepool-standard-action: 0.1.1
ua-parser-js: 1.0.36
Expand Down Expand Up @@ -22237,9 +22237,9 @@ __metadata:
languageName: node
linkType: hard

"tideline@npm:1.38.0-web-3886-basics-view-site-change-regression.1":
version: 1.38.0-web-3886-basics-view-site-change-regression.1
resolution: "tideline@npm:1.38.0-web-3886-basics-view-site-change-regression.1"
"tideline@npm:1.38.0-local-data-source.1":
version: 1.38.0-local-data-source.1
resolution: "tideline@npm:1.38.0-local-data-source.1"
dependencies:
bows: 1.7.2
classnames: 2.3.2
Expand All @@ -22260,7 +22260,7 @@ __metadata:
peerDependencies:
babel-core: 6.x || 7.0.0-bridge.0
lodash: ^4.17.21
checksum: 8277fa09c97f099919ebfeaf86b6e9be5f13f5b73bc9db510e741491059b36795d013c6175c339e51fb119a460de2e2680fa38ce7f33c828b211106fc5a6501d
checksum: 8a24c9e91cd7bcbe2cdbee4d824a6741319dc4f9852236627653b6b81fbb202d887e8a53d5506096178a73000624fb12b58cefb9958212bb3b848682ed7a06cb
languageName: node
linkType: hard

Expand Down
Loading