Skip to content
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

Remove Jellyfish (UPLOAD-1, UPLOAD-1399) #1599

Open
wants to merge 69 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
119e856
remove some old carelink error messages no longer used
gniezen Sep 12, 2023
697acf6
add updatePreviousDurations and api.getLatestRecord
gniezen Sep 18, 2023
c33d91d
Merge branch 'master' into remove-jellyfish
gniezen Sep 20, 2023
19927eb
omnipod changes for platform
gniezen Sep 20, 2023
39085e0
removed all references to jellyfish and dataservices as we now only u…
gniezen Sep 26, 2023
a6242b4
finish moving over changes, including tests
gniezen Sep 26, 2023
0fed1a2
get latest 'status' event, as we don't want to get last alarm
gniezen Oct 18, 2023
cff3376
started work on extended bolus in progress
gniezen Nov 1, 2023
3b582bc
cleanup
gniezen Nov 1, 2023
723b1af
add pumpSettingsOverride fields for validation
gniezen Nov 22, 2023
0075985
load either Jellyfish or platform version of Omnipod and Tandem drivers
gniezen Nov 27, 2023
cbe7f87
Revert "removed all references to jellyfish and dataservices as we no…
gniezen Nov 27, 2023
415418e
both Tandem and Omnipod can be uploaded through Jellyfish or Platform
gniezen Nov 29, 2023
f36a705
Merge branch 'master' into remove-jellyfish
gniezen Nov 29, 2023
952c2a8
all other devices should also use the Jellyfish kill switch
gniezen Nov 29, 2023
a871728
include jellyfish omnipod driver files
gniezen Nov 29, 2023
6954de5
working on sleep/exercise activity active during upload
gniezen Nov 29, 2023
12c8803
checks info endpoint for jellyfish or platform
gniezen Dec 6, 2023
ac6be98
Merge branch 'master' into remove-jellyfish
gniezen Dec 20, 2023
0fd3fe9
v2.55.1-remove-jellyfish.1
gniezen Dec 20, 2023
2dd9436
fix linting
gniezen Dec 20, 2023
381b68a
updatedStatus can be empty
gniezen Jun 24, 2024
6f6213f
Merge branch 'master' into remove-jellyfish
gniezen Jun 24, 2024
7fcb40f
Merge branch 'master' into remove-jellyfish
gniezen Jul 8, 2024
6f00437
sleep schedules is now a map
gniezen Jul 8, 2024
13ecb5b
add option to save POST records in omnipod cli
gniezen Jul 25, 2024
c528c8c
don't upload bolus if already in wizard bolus
gniezen Jul 25, 2024
bca5b19
set current bolus now that bolus is inside wizard record
gniezen Jul 29, 2024
152ac43
add changes to tandem-driver
gniezen Aug 1, 2024
482a529
omnipod cli saves POST records on error
gniezen Aug 12, 2024
09e7b36
update browserslist db
gniezen Aug 12, 2024
5af7457
handle case for suppressed where percent is zero
gniezen Aug 12, 2024
01a6c6f
bolus inside wizard record can be incomplete
gniezen Aug 12, 2024
717f2a7
estimated override duration cannot be negative
gniezen Aug 12, 2024
a1f014f
special values used for zero duration
gniezen Sep 9, 2024
c1c267c
special values for extended volume, BG records; sort BG target as int…
gniezen Sep 9, 2024
f5e16ce
handle cases where updateDuration returns null
gniezen Sep 10, 2024
e582910
combine extended bolus over midnight that got split into two events
gniezen Sep 17, 2024
8819fae
carb inputs can have other special values too
gniezen Sep 23, 2024
cf107b8
possible for the duration left to be zero and still be cancelled
gniezen Sep 23, 2024
d1eddbb
remove completed TODO; delete carryover markers
gniezen Sep 23, 2024
d51bc5c
handle square boluses over midnight too
gniezen Sep 23, 2024
fce7888
calculate duration for all basals
gniezen Sep 23, 2024
27dee49
updating pumpSettingsOverride from previous upload works
gniezen Oct 7, 2024
357437b
Merge branch 'master' into remove-jellyfish
gniezen Oct 8, 2024
c6ec73a
backport changes to Jellyfish drivers
gniezen Oct 8, 2024
7c6871e
handle case where override was active at time of upload and then stopped
gniezen Oct 8, 2024
a7167a5
remove power-only warning when it may overwrite a useful error message
gniezen Oct 14, 2024
5d7cfb3
still need to get user ID and update platform-client
gniezen Oct 17, 2024
0d8b379
use test version of platform-client; use target ID; use api.js
gniezen Oct 17, 2024
d6c3af7
handle canceled during up-front delivery; add test
gniezen Oct 21, 2024
81d7817
v2.59.1-remove-jellyfish.2
gniezen Oct 21, 2024
f8501ca
Merge branch 'master' into remove-jellyfish
gniezen Oct 22, 2024
9f687c8
log error to console
gniezen Oct 28, 2024
226e492
renaming strip() to stripUnwantedFields()
gniezen Oct 28, 2024
7c02d34
address review feedback
gniezen Oct 28, 2024
c3a1274
add test for stripUnwntedFields
gniezen Oct 29, 2024
37c2e1f
add more tests
gniezen Oct 29, 2024
667d594
fix linting
gniezen Oct 29, 2024
df02a50
Merge branch 'master' into remove-jellyfish
gniezen Oct 31, 2024
f79f6c1
fix typo
gniezen Oct 31, 2024
7d6b959
make sure we don't upload pumpSettingsOverride with type normal
gniezen Nov 4, 2024
4540826
update tandem driver
gniezen Nov 4, 2024
d35882b
update tandem driver
gniezen Nov 5, 2024
9f97bc6
handle unusually long durations for omnipod basals and boluses
gniezen Nov 7, 2024
633f019
also handle impossible expected durations
gniezen Nov 7, 2024
f0454b6
wizard boluses are already tied together, so don't add them twice
gniezen Nov 7, 2024
ebcf82d
ignore second carry over flag on Eros
gniezen Nov 7, 2024
2c29b51
don't drop normal boluses that are stacked on during an extended bolu…
gniezen Nov 11, 2024
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
7 changes: 2 additions & 5 deletions app/actions/async.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ export function doAppInit(opts, servicesToInit) {
log('Initializing device');
device.init({
api,
version: opts.namedVersion
version: opts.namedVersion,
uploaderDestination: opts.uploaderDestination,
}, function(deviceError, deviceResult){
if (deviceError) {
return dispatch(sync.initializeAppFailure(deviceError));
Expand Down Expand Up @@ -429,10 +430,6 @@ export function doDeviceUpload(driverId, opts = {}, utc) {
errorMessage = 'E_BLUETOOTH_PAIR';
}

if (targetDevice.powerOnlyWarning) {
errorMessage = 'E_USB_CABLE';
}

device.upload(
driverId,
opts,
Expand Down
4 changes: 0 additions & 4 deletions app/constants/errorMessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@
// and these error constants are a dependency through lib/core/api.js

module.exports = {
E_CARELINK_CREDS: 'Check your CareLink username and password',
E_CARELINK_UNSUPPORTED: 'Tidepool does not support Minimed pumps 522, 722 or older, or the newer 6-series pumps. Sorry... If you are no longer using an unsupported pump and still get this message, create a new CareLink account and try uploading again.',
E_CARELINK_UPLOAD: 'Error processing & uploading CareLink data',
E_DEVICE_UPLOAD: 'Something went wrong during device upload',
E_FETCH_CARELINK: 'Something went wrong trying to fetch CareLink data',
E_FILE_EXT: 'Please choose a file ending in ',
E_HID_CONNECTION: 'Hmm, your device doesn\'t appear to be connected',
E_INIT: 'Error during app initialization',
Expand Down
10 changes: 8 additions & 2 deletions app/containers/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,15 @@ export class App extends Component {
? JSON.parse(localStore.getItem('selectedEnv'))
: null;

this.props.async.fetchInfo(() => {
this.props.async.fetchInfo((err, info) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

it appears we aren't doing anything with the err?

Copy link
Member Author

Choose a reason for hiding this comment

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

If there is an error we already dispatch an error message in fetchInfo itself, so I'll just log it to the console.

if (err) {
this.log('fetchInfo error:', err);
}
this.props.async.doAppInit(
_.assign({ environment: this.state.server }, config, selectedEnv),
_.assign({
environment: this.state.server,
uploaderDestination: info.versions?.uploaderDestination,
}, config, selectedEnv),
{
api: api,
device,
Expand Down
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tidepool-uploader",
"productName": "tidepool-uploader",
"version": "2.59.1-ultra-plus-flex.3",
"version": "2.59.1-remove-jellyfish.2",
"description": "Tidepool Project Universal Uploader",
"main": "./main.prod.js",
"author": {
Expand Down
125 changes: 124 additions & 1 deletion lib/commonFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var annotate = require('./eventAnnotations');
var api = require('./core/api.js');
var rollbar =require('../app/utils/rollbar');
var isBrowser = typeof window !== 'undefined';
var moment = require('moment');
var _ = require('lodash');

var GLUCOSE_MM = 18.01559;

Expand Down Expand Up @@ -177,3 +177,126 @@ exports.addDurationToDeviceTime = function (event, duration) {
};

exports.fixFloatingPoint = (n) => Math.floor(n * 100 + 0.5) / 100;

Number.prototype.toFixedNumber = function(significant){
Copy link
Contributor

Choose a reason for hiding this comment

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

I know it's not exported but is there a test?

Copy link
Member Author

Choose a reason for hiding this comment

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

Added a test.

var pow = Math.pow(10,significant);
return +( Math.round(this*pow) / pow );
};

exports.updateDuration = function(event, lastEvent) {
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a corresponding test?

Copy link
Member Author

Choose a reason for hiding this comment

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

Added a test.


const withAnnotation = function(event) {
if(_.find(event.annotations || [], function(ann) {
return ann.code === 'final-basal/fabricated-from-schedule' ||
ann.code === 'basal/unknown-duration' ||
ann.code === 'status/incomplete-tuple' ||
ann.code === 'bolus/extended-in-progress' ||
ann.code === 'tandem/pumpSettingsOverride/estimated-duration';
})) {
return true;
}
return false;
};

let updatedDuration = Date.parse(event.time) - Date.parse(lastEvent.time);

if (event.extended && event.duration) {
// for extended boluses we don't have to calculate the duration
updatedDuration = event.duration;
}

if (updatedDuration >= 0) {
debug('Updating duration of last event from previous upload');
if((lastEvent.subType !== 'pumpSettingsOverride') && lastEvent.duration > 0) {
lastEvent.expectedDuration = lastEvent.duration;
}
lastEvent.duration = updatedDuration;

if (withAnnotation(lastEvent)) {
// if the event was previously annotated because of the missing event,
// we can now remove the annotations
lastEvent = _.omit(lastEvent, 'annotations');
}

return lastEvent;
} else {
return null;
}
};

exports.stripUnwantedFields = function(record) {
const stripped = _.omit(record,
'createdTime', 'id', 'guid', 'modifiedTime', 'revision', 'uploadId',
'_active', '_deduplicator', '_id', '_schemaVersion', '_userId',
);

debug(`Last ${stripped.type} (${stripped.subType || stripped.deliveryType}) from previous upload was: ${JSON.stringify(stripped, null, 4)}`);
return stripped;
};

exports.updatePreviousDurations = async function(data, cfg, cb) {


try {
// update last basal
const lastBasal = this.stripUnwantedFields(await api.getLatestRecord(cfg.groupId, cfg.deviceInfo.deviceId, 'basal'));
let datum = _.find(data.post_records, {type: 'basal'});
if (datum != null) {
const updatedBasal = this.updateDuration(datum, lastBasal);
if (updatedBasal) {
data.post_records.push(updatedBasal);
}
}

// update last suspend event
if (lastBasal.deliveryType === 'suspend') {
const lastDeviceEvent = this.stripUnwantedFields(await api.getLatestRecord(cfg.groupId, cfg.deviceInfo.deviceId, 'deviceEvent', 'status'));
if (lastDeviceEvent.subType === 'status') {
const index = _.findIndex(data.post_records, {type: 'deviceEvent', subType: 'status'});
datum = data.post_records[index];

if (index > -1) {
const updatedStatus = this.updateDuration(datum, lastDeviceEvent);

if (updatedStatus) {
updatedStatus.reason.resumed = datum.reason.resumed;

if (lastDeviceEvent.payload && lastDeviceEvent.payload.reason != null) {
updatedStatus.payload.suspended = lastDeviceEvent.payload.reason;
delete updatedStatus.payload.reason;
}
if (datum.payload && datum.payload.reason != null) {
updatedStatus.payload.resumed = datum.payload.reason;
}

data.post_records.push(updatedStatus);
data.post_records.splice(index, 1); // remove resume event that is now combined
}
}
}
}

// update last pump settings override
const lastPumpSettingsOverride = this.stripUnwantedFields(await api.getLatestRecord(cfg.groupId, cfg.deviceInfo.deviceId, 'deviceEvent', 'pumpSettingsOverride'));

const index = _.findIndex(data.post_records, {type: 'deviceEvent', subType: 'pumpSettingsOverride'});
datum = data.post_records[index];
if (datum != null) {
if (annotate.isAnnotated(lastPumpSettingsOverride, 'tandem/pumpSettingsOverride/estimated-duration')) {
const updatedOverride = this.updateDuration(datum, lastPumpSettingsOverride);
if (updatedOverride) {
data.post_records.push(updatedOverride);
} else {
debug('Not updating pump settings override as duration could not be calculated');
}
}
if (datum.overrideType === 'normal') {
// remove override active at beginning that was stopped
data.post_records.splice(index, 1);
}
}
return cb (null, data);
} catch (error) {
return cb (error);
}
};
Loading