use of com.activeandroid.query.Select in project xDrip-plus by jamorham.
the class DBSearchUtil method noReadingsBelowRange.
public static int noReadingsBelowRange(Context context) {
Bounds bounds = new Bounds().invoke();
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
boolean mgdl = "mgdl".equals(settings.getString("units", "mgdl"));
double low = Double.parseDouble(settings.getString("lowValue", "70"));
if (!mgdl) {
low *= Constants.MMOLL_TO_MGDL;
}
int count = new Select().from(BgReading.class).where("timestamp >= " + bounds.start).where("timestamp <= " + bounds.stop).where("calculated_value > " + CUTOFF).where("calculated_value < " + low).where("snyced == 0").count();
Log.d("DrawStats", "Low count: " + count);
return count;
}
use of com.activeandroid.query.Select in project xDrip-plus by jamorham.
the class DBSearchUtil method noReadingsAboveRange.
public static int noReadingsAboveRange(Context context) {
Bounds bounds = new Bounds().invoke();
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
boolean mgdl = "mgdl".equals(settings.getString("units", "mgdl"));
double high = Double.parseDouble(settings.getString("highValue", "170"));
if (!mgdl) {
high *= Constants.MMOLL_TO_MGDL;
}
int count = new Select().from(BgReading.class).where("timestamp >= " + bounds.start).where("timestamp <= " + bounds.stop).where("calculated_value > " + CUTOFF).where("calculated_value > " + high).where("snyced == 0").count();
Log.d("DrawStats", "High count: " + count);
return count;
}
use of com.activeandroid.query.Select in project xDrip-plus by jamorham.
the class SlopeParameters method max_recent.
public static double max_recent() {
Sensor sensor = Sensor.currentSensor();
Calibration calibration = new Select().from(Calibration.class).where("Sensor = ? ", sensor.getId()).where("slope_confidence != 0").where("sensor_confidence != 0").where("timestamp > ?", (new Date().getTime() - (60000 * 60 * 24 * 4))).orderBy("bg desc").executeSingle();
if (calibration != null) {
return calibration.bg;
} else {
return 120;
}
}
use of com.activeandroid.query.Select in project xDrip-plus by jamorham.
the class AlertType method toSettings.
// Convert all settings to a string and save it in the references. This is needed to allow it's backup.
public static boolean toSettings(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
List<AlertType> alerts = new Select().from(AlertType.class).execute();
Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().registerTypeAdapter(Date.class, new DateTypeAdapter()).serializeSpecialFloatingPointValues().create();
String output = gson.toJson(alerts);
Log.e(TAG, "Created the string " + output);
prefs.edit().putString("saved_alerts", output).commit();
return true;
}
use of com.activeandroid.query.Select in project xDrip-plus by jamorham.
the class Treatments method latestForGraphSystime.
public static List<Treatments> latestForGraphSystime(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("systimestamp >= ? and systimestamp <= ?", df.format(startTime), df.format(endTime)).orderBy("systimestamp asc").limit(number).execute();
}
Aggregations