Skip to content
Merged
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
6 changes: 5 additions & 1 deletion lib/iob/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ function calcTempTreatments (inputs, zeroTempDuration) {
temp.date = temp.started_at.getTime();
temp.insulin = current.insulin;
tempBoluses.push(temp);
} else if (current.eventType == "Temp Basal" && current.enteredBy=="HAPP_App") {
} else if (current.eventType == "Temp Basal" && (current.enteredBy == "HAPP_App" || current.enteredBy == "openaps://AndroidAPS")) {
var temp = {};
temp.rate = current.absolute;
temp.duration = current.duration;
Expand Down Expand Up @@ -357,6 +357,10 @@ function calcTempTreatments (inputs, zeroTempDuration) {
for (var i=0; i+1 < tempHistory.length; i++) {
if (tempHistory[i].date + tempHistory[i].duration*60*1000 > tempHistory[i+1].date) {
tempHistory[i].duration = (tempHistory[i+1].date - tempHistory[i].date)/60/1000;
// Delete AndroidAPS "Cancel TBR records" in which duration is not populated
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure I follow the comment / logic here. can you explain how this part works?

Copy link
Contributor Author

@philipgo philipgo Jul 17, 2018

Choose a reason for hiding this comment

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

AndroidAPS cancels TBRs in Nightscout by creating a subsequent TBR entry in which rate and duration fields do not exist. My idea of the logic here was to use the AndroidAPS "Cancel TBR" records to adjust the duration of the previously running TBR. Afterwards these "Cancel TBR" records are not needed anymore and can be deleted. However, not deleting them does not seem to affect Autotune results, it only causes a lot of empty array elements when running Autotune on AAPS data.

if (tempHistory[i+1].duration == null) {
tempHistory.splice(i+1, 1);
}
}
}

Expand Down