Make TreatmentsPlugin.getLastBolusTime robust.
Ignore carb-only treatments, ignore future records. (cherry picked from commit cba015e)
This commit is contained in:
parent
b4d13c727e
commit
b1fd66aae5
1 changed files with 3 additions and 5 deletions
|
@ -288,12 +288,10 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
|||
|
||||
@Override
|
||||
public long getLastBolusTime() {
|
||||
long now = System.currentTimeMillis();
|
||||
long last = 0;
|
||||
for (Integer pos = 0; pos < treatments.size(); pos++) {
|
||||
Treatment t = treatments.get(pos);
|
||||
if (!t.isValid)
|
||||
continue;
|
||||
if (t.date > last)
|
||||
for (Treatment t : treatments) {
|
||||
if (t.date > last && t.insulin > 0 && t.isValid && t.date <= now)
|
||||
last = t.date;
|
||||
}
|
||||
log.debug("Last bolus time: " + new Date(last).toLocaleString());
|
||||
|
|
Loading…
Reference in a new issue