Merge pull request #704 from Philoul/Fix/Java/FixMissingBolus

Fix missing bolus Insight Driver
This commit is contained in:
Milos Kozak 2021-10-02 00:20:07 +02:00 committed by GitHub
commit e96331b228
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1433,7 +1433,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Constrai
bolusID = insightDbHelper.getInsightBolusID(serial, event.getBolusID(), startTimestamp); // Line added to get id bolusID = insightDbHelper.getInsightBolusID(serial, event.getBolusID(), startTimestamp); // Line added to get id
if (event.getBolusType() == BolusType.STANDARD || event.getBolusType() == BolusType.MULTIWAVE) { if (event.getBolusType() == BolusType.STANDARD || event.getBolusType() == BolusType.MULTIWAVE) {
pumpSync.syncBolusWithPumpId( pumpSync.syncBolusWithPumpId(
startTimestamp, bolusID.getTimestamp(),
event.getImmediateAmount(), event.getImmediateAmount(),
null, null,
bolusID.getId(), bolusID.getId(),
@ -1443,7 +1443,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Constrai
if (event.getBolusType() == BolusType.EXTENDED || event.getBolusType() == BolusType.MULTIWAVE) { if (event.getBolusType() == BolusType.EXTENDED || event.getBolusType() == BolusType.MULTIWAVE) {
if (event.getDuration() > 0 && profileFunction.getProfile(bolusID.getTimestamp()) != null) if (event.getDuration() > 0 && profileFunction.getProfile(bolusID.getTimestamp()) != null)
pumpSync.syncExtendedBolusWithPumpId( pumpSync.syncExtendedBolusWithPumpId(
startTimestamp, bolusID.getTimestamp(),
event.getExtendedAmount(), event.getExtendedAmount(),
timestamp - startTimestamp, timestamp - startTimestamp,
isFakingTempsByExtendedBoluses(), isFakingTempsByExtendedBoluses(),
@ -1557,8 +1557,6 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Constrai
} }
private long parseRelativeDate(int year, int month, int day, int hour, int minute, int second, int relativeHour, int relativeMinute, int relativeSecond) { private long parseRelativeDate(int year, int month, int day, int hour, int minute, int second, int relativeHour, int relativeMinute, int relativeSecond) {
if (relativeHour * 60 * 60 + relativeMinute * 60 + relativeSecond >= hour * 60 * 60 * minute * 60 + second)
day--;
Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
calendar.set(Calendar.YEAR, year); calendar.set(Calendar.YEAR, year);
calendar.set(Calendar.MONTH, month - 1); calendar.set(Calendar.MONTH, month - 1);
@ -1566,7 +1564,9 @@ public class LocalInsightPlugin extends PumpPluginBase implements Pump, Constrai
calendar.set(Calendar.HOUR_OF_DAY, relativeHour); calendar.set(Calendar.HOUR_OF_DAY, relativeHour);
calendar.set(Calendar.MINUTE, relativeMinute); calendar.set(Calendar.MINUTE, relativeMinute);
calendar.set(Calendar.SECOND, relativeSecond); calendar.set(Calendar.SECOND, relativeSecond);
return calendar.getTimeInMillis(); long dayOffset =
relativeHour * 60 * 60 + relativeMinute * 60 + relativeSecond >= hour * 60 * 60 + minute * 60 + second ? T.Companion.days(1).msecs() : 0L;
return calendar.getTimeInMillis() - dayOffset;
} }
private void uploadCareportalEvent(long date, DetailedBolusInfo.EventType event) { private void uploadCareportalEvent(long date, DetailedBolusInfo.EventType event) {