Skip to content

Commit ef0b1f1

Browse files
committed
[BACK-2685] also grab related upload record
1 parent b04c3ed commit ef0b1f1

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

lib/report.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,41 @@ class Report {
720720
if (pumpSettingsFetch?.length > 0) {
721721
userData.push(pumpSettingsFetch[0]);
722722
}
723+
724+
const latestPumpSettings = find(userData, {
725+
type: 'pumpSettings',
726+
});
727+
728+
const latestPumpSettingsUploadId = get(
729+
latestPumpSettings || {},
730+
'uploadId',
731+
);
732+
733+
const latestPumpSettingsUpload = find(userData, {
734+
type: 'upload',
735+
uploadId: latestPumpSettingsUploadId,
736+
});
737+
738+
if (latestPumpSettingsUploadId && !latestPumpSettingsUpload) {
739+
// If we have pump settings, but we don't have the corresponing upload record used
740+
// to get the device source, we need to fetch it
741+
const pumpSettingsUploadFetch = await fetchUserData(
742+
this.#userDetail.userId,
743+
{
744+
headers: this.#requestData.sessionHeader,
745+
params: {
746+
type: 'upload',
747+
uploadId: latestPumpSettingsUploadId,
748+
},
749+
},
750+
).catch((error) => {
751+
this.#log.error(error);
752+
});
753+
754+
if (pumpSettingsUploadFetch?.length > 0) {
755+
userData.push(pumpSettingsUploadFetch[0]);
756+
}
757+
}
723758
}
724759

725760
this.#log.debug(`Downloading data for User ${this.#userDetail.userId}...`);

0 commit comments

Comments
 (0)