Skip to content

Commit

Permalink
Merge pull request #1650 from tidepool-org/handle-empty
Browse files Browse the repository at this point in the history
Improve messaging when there are no (new) records (UPLOAD-1295)
  • Loading branch information
gniezen authored Oct 3, 2024
2 parents 448e611 + 7509ea2 commit 7537217
Show file tree
Hide file tree
Showing 26 changed files with 122 additions and 46 deletions.
10 changes: 10 additions & 0 deletions app/actions/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,16 @@ export function makeUploadCb(dispatch, getState, errCode, utc) {
uploadErrProps.details = 'Could not validate the date format';
}

if (err.code === 'E_NO_RECORDS') {
displayErr.message = ErrorMessages.E_NO_RECORDS;
displayErr.code = 'E_NO_RECORDS';
}

if (err.code === 'E_NO_NEW_RECORDS') {
displayErr.message = ErrorMessages.E_NO_NEW_RECORDS;
displayErr.code = 'E_NO_NEW_RECORDS';
}

if (process.env.NODE_ENV !== 'test') {
uploadErrProps = await sendToRollbar(displayErr, uploadErrProps);
}
Expand Down
41 changes: 28 additions & 13 deletions app/components/UploadList.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default class UploadList extends Component {

static defaultProps = {
text: {
UPLOAD_FAILED : i18n.t('Upload Failed')
UPLOAD_FAILED: i18n.t('Upload Failed')
}
};

Expand Down Expand Up @@ -85,7 +85,7 @@ export default class UploadList extends Component {
const { disabled, onReset, onUpload, targetId } = this.props;

const headlineText = this.props.renderClinicUi ? i18n.t('Devices') : i18n.t('Upload Devices');
const medtronicEnabled = _.findIndex(this.props.uploads, {key:'medtronic'}) === -1 ? false : true;
const medtronicEnabled = _.findIndex(this.props.uploads, { key: 'medtronic' }) === -1 ? false : true;
const items = _.map(this.props.uploads, (upload) => {
if (upload.name) {
if (upload.key === 'carelink') {
Expand Down Expand Up @@ -236,7 +236,7 @@ export default class UploadList extends Component {
if (this.state.uploadErrorSubmitSuccessSet.includes(errorId)) {
sendToSupport = (
<div className={styles.errorSubmitSuccess}>
<CheckCircle className={styles.errorLinkIcon} sx={{height:'0.8em', width:'0.8em'}} />
<CheckCircle className={styles.errorLinkIcon} sx={{ height: '0.8em', width: '0.8em' }} />
{i18n.t(
'Thanks for sharing. Someone will get back to you by email soon.'
)}
Expand Down Expand Up @@ -275,22 +275,37 @@ export default class UploadList extends Component {
href="#"
onClick={this.handleErrorSubmit.bind(this, upload.error)}
>
<Email className={styles.errorLinkIcon} sx={{height:'0.8em', width:'0.8em'}} />
<Email className={styles.errorLinkIcon} sx={{ height: '0.8em', width: '0.8em' }} />
{i18n.t('Share this issue with the Tidepool Support Team')}
</a>
</div>
);
}

return (
<div className={styles.errorItem}>
{errorMessage}
{errorDetails}
{rollbarUUID}
{sendToSupport}
</div>
);
}
if (upload.error.code === 'E_NO_RECORDS' || upload.error.code === 'E_NO_NEW_RECORDS') {
return (
<div className={styles.errorItem}>
<div className={styles.errorMessageWrapper}>
<span className={styles.boldMessage}>{i18n.t('Data is up to date')}</span>
<span className={styles.errorMessageFriendly}>
&nbsp;&#8212; {i18n.t(upload.error.message)}
</span>
</div>
{rollbarUUID}
{sendToSupport}
</div>
);
} else {
return (
<div className={styles.errorItem}>
{errorMessage}
{errorDetails}
{rollbarUUID}
{sendToSupport}
</div>
);
}
}

noopHandler(e){
e.preventDefault();
Expand Down
3 changes: 2 additions & 1 deletion app/constants/errorMessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ module.exports = {
E_DEXCOM_CONNECTION: 'Tidepool is having trouble connecting to your Dexcom receiver. Please make sure your other Dexcom uploading software programs are closed (like Dexcom Clarity or Glooko/Diasend). You can also try using another micro-USB cable. Some micro-USB cables are designed to carry a signal for power only.',
E_USB_CABLE: 'Your device doesn\'t appear to be connected. You can try using another USB cable, as some USB cables are designed to carry a signal for power only.',
E_NOT_YET_READY: 'Your device is not yet ready or not plugged in',
E_NO_NEW_RECORDS: 'No new records to upload',
E_NO_NEW_RECORDS: 'There is no new data since last time. If you think this is an error, please reach out below.',
E_NO_RECORDS: 'There is no data on the device. If you think this is an error, please reach out below.',
E_DATETIME_SET_BY_PUMP: 'Please correct the date/time on the linked pump.',
ERR_FETCHING_CLINICS_FOR_CLINICIAN: 'Something went wrong while getting clinics for clinician.',
ERR_FETCHING_ASSOCIATED_ACCOUNTS: 'Something went wrong while fetching associated accounts.',
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",
"version": "2.59.1-handle-empty.4",
"description": "Tidepool Project Universal Uploader",
"main": "./main.prod.js",
"author": {
Expand Down
8 changes: 5 additions & 3 deletions lib/driverManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,12 @@ module.exports = function (driverObjects, configs) {
debug('Compressing packets..');
const deflate = new pako.Deflate({ gzip: true });
deflate.push(dataBinary, false); // metadata
for (let i = 0; i < data.packets.length - 1; i++) {
deflate.push(data.packets[i], false);
if (data.packets.length > 1) {
for (let i = 0; i < data.packets.length - 1; i++) {
deflate.push(data.packets[i], false);
}
deflate.push(data.packets[i+1], true); // finalize
}
deflate.push(data.packets[i+1], true); // finalize

if (deflate.err) {
throw new Error(deflate.err);
Expand Down
5 changes: 4 additions & 1 deletion lib/drivers/abbott/abbottFreeStyleLibre.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,10 @@ export default function (config) {
debug('processData: num post records:', data.post_records.length);

if (data.post_records.length === 0) {
return cb(new Error('Device has no records to upload'), null);
debug('Device has no records to upload');
const err = new Error('No records to upload');
err.code = 'E_NO_RECORDS';
return cb(err, null);
}

progress(100);
Expand Down
4 changes: 3 additions & 1 deletion lib/drivers/abbott/abbottFreeStyleNeo.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,9 @@ module.exports = (config) => {

if (data.post_records.length === 0) {
debug('Device has no records to upload');
return cb(new Error('Device has no records to upload'), null);
const err = new Error('No records to upload');
err.code = 'E_NO_RECORDS';
return cb(err, null);
}
progress(100);
return cb(null, data);
Expand Down
4 changes: 3 additions & 1 deletion lib/drivers/bayer/bayerContour.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,9 @@ module.exports = (config) => {
}
} else {
debug('Device has no records to upload');
throw (new Error('Device has no records to upload'));
const err = new Error('No records to upload');
err.code = 'E_NO_RECORDS';
throw err;
}

return dataToPost;
Expand Down
4 changes: 3 additions & 1 deletion lib/drivers/bayer/bayerContourNext.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,9 @@ module.exports = function (config) {
}
} else {
debug('Device has no records to upload');
throw(new Error('Device has no records to upload'));
const err = new Error('No records to upload');
err.code = 'E_NO_RECORDS';
throw err;
}

return dataToPost;
Expand Down
25 changes: 16 additions & 9 deletions lib/drivers/bluetoothLE/bluetoothLEDriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,16 @@ module.exports = (config) => {
cfg.deviceInfo.deviceId += `-${remote.getGlobal('bluetoothDeviceId')}`;
} else {
cfg.deviceInfo.deviceId += `-${cfg.deviceComms.ble.device.id}`;
}
}

cfg.builder.setDefaults({ deviceId: cfg.deviceInfo.deviceId });

if (cfg.deviceInfo.name.startsWith('CareSens') ||
if (cfg.deviceInfo.name.startsWith('CareSens') ||
cfg.deviceInfo.name.startsWith('ReliOn 2395') ||
cfg.deviceInfo.name.startsWith('ReliOn 0015')) {

let abortTimer = null;

(async () => {
try {
cfg.deviceComms.ble.customService = await cfg.deviceComms.ble.server.getPrimaryService(0xFFF0);
Expand Down Expand Up @@ -156,7 +156,7 @@ module.exports = (config) => {
sundial.formatInTimezone(serverTime, cfg.timezone, 'm'),
sundial.formatInTimezone(serverTime, cfg.timezone, 's')
);

try {
// we don't wait for a confirmation, as it takes too long for the
// meter to reply with the updated time
Expand Down Expand Up @@ -201,7 +201,7 @@ module.exports = (config) => {
fetchData(progress, data, cb) {
debug('in fetchData', data);
let retryTimer = null;

api.getMostRecentUploadRecord(cfg.groupId, cfg.deviceInfo.deviceId, function(err, lastUpload) {
if (err) {
return cb(err);
Expand All @@ -212,7 +212,7 @@ module.exports = (config) => {
if (data.lastEndPosition) {
debug('Last record read was', data.lastEndPosition, ', starting from there');
}

const abortTimer = setTimeout(() => {
debug('TIMEOUT');
return cb('Timeout error. Did the meter pair succesfully?', null);
Expand Down Expand Up @@ -248,7 +248,7 @@ module.exports = (config) => {
}, 1000);

try {

if (data.lastEndPosition && uploadDataPeriod.periodGlobal === uploadDataPeriod.PERIODS.DELTA) {
debug('Getting number of new records..');
await cfg.deviceComms.ble.getDeltaNumberOfRecords(data.lastEndPosition + 1);
Expand Down Expand Up @@ -353,8 +353,15 @@ module.exports = (config) => {
debug('POST records:', data.post_records);

if (data.post_records.length === 0) {
debug('Device has no records to upload');
return cb(new Error('Device has no records to upload'), null);
const err = new Error('No records');
if (data.lastEndPosition > 0) {
debug('Device has no new records to upload');
err.code = 'E_NO_NEW_RECORDS';
} else {
debug('Device has no records to upload');
err.code = 'E_NO_RECORDS';
}
return cb(err, null);
}

progress(100);
Expand Down
4 changes: 3 additions & 1 deletion lib/drivers/dexcom/dexcomDriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,9 @@ module.exports = (config) => {
// 0xFFFFFFFF is returned for the first and last index
// when there are no records in the partition
if (recordType === RECORD_TYPES.EGV_DATA || recordType === RECORD_TYPES.BACKFILLED_EGV_DATA) {
return callback(new Error('We found no data on this Dexcom receiver.'));
const error = new Error('No records to upload');
error.code = 'E_NO_RECORDS';
return callback(error, null);
}
// return empty array if there are no calibration records or settings
return callback(null, []);
Expand Down
4 changes: 3 additions & 1 deletion lib/drivers/glucorx/glucoRxDriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,9 @@ module.exports = (config) => {

if (data.post_records.length === 0) {
debug('Device has no records to upload');
return cb(new Error('Device has no records to upload'), null);
const err = new Error('No records to upload');
err.code = 'E_NO_RECORDS';
return cb(err, null);
}
progress(100);
return cb(null, data);
Expand Down
4 changes: 3 additions & 1 deletion lib/drivers/i-sens/careSens.js
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 +987,9 @@ module.exports = (config) => {

if (data.post_records.length === 0) {
debug('Device has no records to upload');
return cb(new Error('Device has no records to upload'), null);
const err = new Error('No records to upload');
err.code = 'E_NO_RECORDS';
return cb(err, null);
}
progress(100);
return cb(null, data);
Expand Down
4 changes: 3 additions & 1 deletion lib/drivers/i-sens/glucocardExpression.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,9 @@ module.exports = (config) => {

if (data.post_records.length === 0) {
debug('Device has no records to upload');
return cb(new Error('Device has no records to upload'), null);
const err = new Error('No records to upload');
err.code = 'E_NO_RECORDS';
return cb(err, null);
}
progress(100);
return cb(null, data);
Expand Down
4 changes: 3 additions & 1 deletion lib/drivers/i-sens/reliOnPrime.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,9 @@ module.exports = (config) => {
}
} else {
debug('Device has no records to upload');
throw (new Error('Device has no records to upload'));
const err = new Error('No records to upload');
err.code = 'E_NO_RECORDS';
throw err;
}

return dataToPost;
Expand Down
4 changes: 3 additions & 1 deletion lib/drivers/medtronic/medtronicDriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -1595,7 +1595,9 @@ module.exports = function (config) {

var dateRecords = _.filter(records, function(event) {return event.jsDate;}); // filter out objects without dates
if(dateRecords.length === 0) {
return cb(new Error('No records found on pump'), null);
const err = new Error('No records to upload');
err.code = 'E_NO_RECORDS';
return cb(err, null);
}
var mostRecent = sundial.applyTimezone(dateRecords[dateRecords.length-1].jsDate, cfg.timezone).toISOString();
proc.init(cfg, data.settings);
Expand Down
4 changes: 3 additions & 1 deletion lib/drivers/onetouch/oneTouchUltraMini.js
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,9 @@ module.exports = function (config) {
dataToPost.push(smbg.done());
}
}else{
debug('Device has no records to upload');
const err = new Error('No records to upload');
err.code = 'E_NO_RECORDS';
throw err;
}

return dataToPost;
Expand Down
4 changes: 3 additions & 1 deletion lib/drivers/onetouch/oneTouchVerio.js
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,9 @@ export default function (config) {
debug('fetchData: recordCount: ', resultData1.recordCount);
if (resultData1.recordCount === 0) {
data.records = [];
cb(new Error('Device has no records to upload'), null);
const err = new Error('No records to upload');
err.code = 'E_NO_RECORDS';
cb(err, null);
return;
}

Expand Down
4 changes: 3 additions & 1 deletion lib/drivers/onetouch/oneTouchVerioBLE.js
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,9 @@ export default (config) => {

if (data.post_records.length === 0) {
debug('Device has no records to upload');
return cb(new Error('Device has no records to upload'), null);
const err = new Error('No records to upload');
err.code = 'E_NO_RECORDS';
return cb(err, null);
}

progress(100);
Expand Down
3 changes: 3 additions & 0 deletions lib/drivers/onetouch/oneTouchVerioIQ.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,9 @@ module.exports = function (config) {
}
}else{
debug('Device has no records to upload');
const err = new Error('No records to upload');
err.code = 'E_NO_RECORDS';
throw err;
}

return dataToPost;
Expand Down
4 changes: 3 additions & 1 deletion lib/drivers/roche/accuChekUSB.js
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,9 @@ module.exports = (config) => {

if (data.postRecords.length === 0) {
debug('Device has no records to upload');
return cb(new Error('Device has no records to upload'), null);
const err = new Error('No records to upload');
err.code = 'E_NO_RECORDS';
return cb(err, null);
}
progress(100);
return cb(null, data);
Expand Down
2 changes: 1 addition & 1 deletion lib/drivers/tandem
4 changes: 3 additions & 1 deletion lib/drivers/trividia/trueMetrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@ module.exports = (config) => {

if (data.postRecords.length === 0) {
debug('Device has no records to upload');
return cb(new Error('Device has no records to upload'), null);
const err = new Error('No records to upload');
err.code = 'E_NO_RECORDS';
return cb(err, null);
}
progress(100);
return cb(null, data);
Expand Down
7 changes: 5 additions & 2 deletions locales/en/translation.missing.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@
"See what's new with Tidepool Uploader": "See what's new with Tidepool Uploader",
"You can continue to use your current version,": "You can continue to use your current version,",
"but we recommend updating as soon as possible.": "but we recommend updating as soon as possible.",
"Unlock PDM. Plug into USB. Tap Export on PDM. Click Upload.": "Unlock PDM. Plug into USB. Tap Export on PDM. Click Upload.",
"Plug in PDA with micro-USB": "Plug in PDA with micro-USB",
"Share this issue with the Tidepool Support Team": "Share this issue with the Tidepool Support Team"
"There is no new data since last time. If you think this is an error, please reach out below.": "There is no new data since last time. If you think this is an error, please reach out below.",
"Share this issue with the Tidepool Support Team": "Share this issue with the Tidepool Support Team",
"Data is up to date": "Data is up to date",
"There is no data on the device. If you think this is an error, please reach out below.": "There is no data on the device. If you think this is an error, please reach out below.",
"Unlock PDM. Plug into USB. Tap Export on PDM. Click Upload.": "Unlock PDM. Plug into USB. Tap Export on PDM. Click Upload."
}
Loading

0 comments on commit 7537217

Please sign in to comment.