Check both created_at and timestamp fields for treatments in if-modified-since logic

This commit is contained in:
Sulka Haro
2017-10-25 23:48:49 +03:00
parent 0efaffa4b1
commit c16ad7b989
+11 -1
View File
@@ -40,8 +40,18 @@ function configure(app, wares, ctx) {
t.carbs = Number(t.carbs);
t.insulin = Number(t.insulin);
var d2 = new Date(t.timestamp);
var d2 = null;
if (t.hasOwnProperty('created_at')) {
d2 = new Date(t.created_at);
} else {
if (t.hasOwnProperty('timestamp')) {
d2 = new Date(t.timestamp);
}
}
if (d2 == null) { return; }
if (d1 == null || d2.getTime() > d1.getTime()) {
d1 = d2;
}