use of com.activeandroid.query.Select in project xDrip-plus by jamorham.
the class BgReading method getForTimestamp.
public static BgReading getForTimestamp(double timestamp) {
Sensor sensor = Sensor.currentSensor();
if (sensor != null) {
BgReading bgReading = new Select().from(BgReading.class).where("Sensor = ? ", sensor.getId()).where("timestamp <= ?", // 1 minute padding (should never be that far off, but why not)
(timestamp + (60 * 1000))).where("calculated_value = 0").where("raw_calculated = 0").orderBy("timestamp desc").executeSingle();
if (bgReading != null && Math.abs(bgReading.timestamp - timestamp) < (3 * 60 * 1000)) {
// cool, so was it actually within 4 minutes of that bg reading?
Log.i(TAG, "getForTimestamp: Found a BG timestamp match");
return bgReading;
}
}
Log.d(TAG, "getForTimestamp: No luck finding a BG timestamp match");
return null;
}
use of com.activeandroid.query.Select in project xDrip-plus by jamorham.
the class BgReading method getForTimestampExists.
// used in wear
public static BgReading getForTimestampExists(double timestamp) {
Sensor sensor = Sensor.currentSensor();
if (sensor != null) {
BgReading bgReading = new Select().from(BgReading.class).where("Sensor = ? ", sensor.getId()).where("timestamp <= ?", // 1 minute padding (should never be that far off, but why not)
(timestamp + (60 * 1000))).orderBy("timestamp desc").executeSingle();
if (bgReading != null && Math.abs(bgReading.timestamp - timestamp) < (3 * 60 * 1000)) {
// cool, so was it actually within 4 minutes of that bg reading?
Log.i(TAG, "getForTimestamp: Found a BG timestamp match");
return bgReading;
}
}
Log.d(TAG, "getForTimestamp: No luck finding a BG timestamp match");
return null;
}
use of com.activeandroid.query.Select in project xDrip-plus by jamorham.
the class BgReading method is_new.
public static boolean is_new(SensorRecord sensorRecord, long addativeOffset) {
double timestamp = sensorRecord.getSystemTime().getTime() + addativeOffset;
Sensor sensor = Sensor.currentSensor();
if (sensor != null) {
BgReading bgReading = new Select().from(BgReading.class).where("Sensor = ? ", sensor.getId()).where("timestamp <= ?", // 1 minute padding (should never be that far off, but why not)
(timestamp + (60 * 1000))).orderBy("timestamp desc").executeSingle();
if (bgReading != null && Math.abs(bgReading.timestamp - timestamp) < (3 * 60 * 1000)) {
// cool, so was it actually within 4 minutes of that bg reading?
Log.i(TAG, "isNew; Old Reading");
return false;
}
}
Log.i(TAG, "isNew: New Reading");
return true;
}
use of com.activeandroid.query.Select in project xDrip-plus by jamorham.
the class UserError method deletable.
public static List<UserError> deletable() {
List<UserError> userErrors = new Select().from(UserError.class).where("severity < ?", 3).where("timestamp < ?", (new Date().getTime() - 1000 * 60 * 60 * 24)).orderBy("timestamp desc").execute();
List<UserError> highErrors = new Select().from(UserError.class).where("severity = ?", 3).where("timestamp < ?", (new Date().getTime() - 1000 * 60 * 60 * 24 * 3)).orderBy("timestamp desc").execute();
List<UserError> events = new Select().from(UserError.class).where("severity > ?", 3).where("timestamp < ?", (new Date().getTime() - 1000 * 60 * 60 * 24 * 7)).orderBy("timestamp desc").execute();
userErrors.addAll(highErrors);
userErrors.addAll(events);
return userErrors;
}
use of com.activeandroid.query.Select in project xDrip-plus by jamorham.
the class Treatments method latestForGraph.
public static List<Treatments> latestForGraph(int number, double startTime, double endTime) {
fixUpTable();
DecimalFormat df = new DecimalFormat("#");
// are there decimal points in the database??
df.setMaximumFractionDigits(1);
return new Select().from(Treatments.class).where("timestamp >= ? and timestamp <= ?", df.format(startTime), df.format(endTime)).orderBy("timestamp desc").limit(number).execute();
}
Aggregations