use of com.activeandroid.query.Select in project xDrip by NightscoutFoundation.
the class UploaderQueue method getCount.
private static int getCount(String where) {
try {
final String query = new Select("COUNT(*) as total").from(UploaderQueue.class).toSql();
final Cursor resultCursor = Cache.openDatabase().rawQuery(query + where, null);
if (resultCursor.moveToNext()) {
final int total = resultCursor.getInt(0);
resultCursor.close();
return total;
} else {
return 0;
}
} catch (Exception e) {
Log.d(TAG, "Got exception getting count: " + e);
return 0;
}
}
use of com.activeandroid.query.Select in project xDrip by NightscoutFoundation.
the class UploaderQueue method getClasses.
private static List<String> getClasses() {
fixUpTable();
final ArrayList<String> results = new ArrayList<>();
final String query = new Select("distinct otype as otypes").from(UploaderQueue.class).toSql();
final Cursor resultCursor = Cache.openDatabase().rawQuery(query, null);
while (resultCursor.moveToNext()) {
results.add(resultCursor.getString(0));
}
resultCursor.close();
return results;
}
use of com.activeandroid.query.Select in project xDrip by NightscoutFoundation.
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();
}
use of com.activeandroid.query.Select in project xDrip by NightscoutFoundation.
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();
}
use of com.activeandroid.query.Select in project xDrip-plus by jamorham.
the class UserError method bySeverity.
public static List<UserError> bySeverity(Integer[] levels) {
String levelsString = " ";
for (int level : levels) {
levelsString += level + ",";
}
Log.d("UserError", "severity in (" + levelsString.substring(0, levelsString.length() - 1) + ")");
return new Select().from(UserError.class).where("severity in (" + levelsString.substring(0, levelsString.length() - 1) + ")").orderBy("timestamp desc").limit(// too many data can kill akp
10000).execute();
}
Aggregations