public static BgReading readingNearTimeStamp(double startTime) { final double margin = (4 * 60 * 1000); final DecimalFormat df = new DecimalFormat("#"); df.setMaximumFractionDigits(1); return new Select() .from(BgReading.class) .where("timestamp >= " + df.format(startTime - margin)) .where("timestamp <= " + df.format(startTime + margin)) .where("calculated_value != 0") .where("raw_data != 0") .executeSingle(); }
public static List<BgReading> latestForGraphAsc(int number, long startTime, long endTime) {//KS return new Select() .from(BgReading.class) .where("timestamp >= " + Math.max(startTime, 0)) .where("timestamp <= " + endTime) .where("calculated_value != 0") .where("raw_data != 0") .orderBy("timestamp asc") .limit(number) .execute(); }
public static List<Calibration> futureCalibrations() { double timestamp = new Date().getTime(); return new Select() .from(Calibration.class) .where("timestamp > " + timestamp) .orderBy("timestamp desc") .execute(); }
public static Reminder byid(long id) { return new Select() .from(Reminder.class) .where("_ID = ?", id) .executeSingle(); }
public static TransmitterData findByUuid(String uuid) {//KS try { return new Select() .from(TransmitterData.class) .where("uuid = ?", uuid) .executeSingle(); } catch (Exception e) { Log.e(TAG,"findByUuid() Got exception on Select : "+e.toString()); return null; } }
public static BgReading findByUuid(String uuid) { return new Select() .from(BgReading.class) .where("uuid = ?", uuid) .executeSingle(); }
public static Calibration findByUuid(String uuid) { return new Select() .from(Calibration.class) .where("uuid = ?", uuid) .executeSingle(); }
public static BloodTest byid(long id) { try { return new Select() .from(BloodTest.class) .where("_ID = ?", id) .executeSingle(); } catch (android.database.sqlite.SQLiteException e) { fixUpTable(); return null; } }
public static List<BloodTest> cleanup(int retention_days) { return new Delete() .from(BloodTest.class) .where("timestamp < ?", JoH.tsl() - (retention_days * Constants.DAY_IN_MS)) .execute(); }
public static BloodTest byUUID(String uuid) { if (uuid == null) return null; try { return new Select() .from(BloodTest.class) .where("uuid = ?", uuid) .executeSingle(); } catch (android.database.sqlite.SQLiteException e) { fixUpTable(); return null; } }
public static List<BloodTest> cleanup(int retention_days) { return new Delete() .from(BloodTest.class) .where("timestamp < ?", JoH.tsl() - (retention_days * Constants.DAY_IN_MS)) .execute(); }
public static List<BgReading> cleanup(int retention_days) { return new Delete() .from(BgReading.class) .where("timestamp < ?", JoH.tsl() - (retention_days * Constants.DAY_IN_MS)) .execute(); }
public static UserNotification lastBgAlert() { return new Select() .from(UserNotification.class) .where("bg_alert = ?", true) .orderBy("_ID desc") .executeSingle(); } public static UserNotification lastCalibrationAlert() {
public static UserNotification lastExtraCalibrationAlert() { return new Select() .from(UserNotification.class) .where("extra_calibration_alert = ?", true) .orderBy("_ID desc") .executeSingle(); }
public static BloodTest byUUID(String uuid) { if (uuid == null) return null; try { return new Select() .from(BloodTest.class) .where("uuid = ?", uuid) .executeSingle(); } catch (android.database.sqlite.SQLiteException e) { fixUpTable(); return null; } }
public static SensorSendQueue nextSensorJob() { SensorSendQueue job = new Select() .from(SensorSendQueue.class) .where("success =", false) .orderBy("_ID desc") .limit(1) .executeSingle(); return job; }
public static List<Calibration> latest(int number) { Sensor sensor = Sensor.currentSensor(); if (sensor == null) { return null; } return new Select() .from(Calibration.class) .where("Sensor = ? ", sensor.getId()) .orderBy("timestamp desc") .limit(number) .execute(); }