use of com.activeandroid.query.Select in project xDrip-plus by jamorham.
the class Reminder method getNextActiveReminder.
public static Reminder getNextActiveReminder() {
fixUpTable(schema);
final long now = JoH.tsl();
final Reminder reminder = new Select().from(Reminder.class).where("enabled = ?", true).where("next_due < ?", now).where("snoozed_till < ?", now).where("last_fired < (? - (600000 * alerted_times))", now).orderBy("enabled desc, priority desc, next_due asc").executeSingle();
return reminder;
}
use of com.activeandroid.query.Select in project xDrip-plus by jamorham.
the class LibreBlock method getForTimestamp.
public static LibreBlock getForTimestamp(long timestamp) {
final double margin = (3 * 1000);
final DecimalFormat df = new DecimalFormat("#");
df.setMaximumFractionDigits(1);
return new Select().from(LibreBlock.class).where("timestamp >= " + df.format(timestamp - margin)).where("timestamp <= " + df.format(timestamp + margin)).executeSingle();
}
use of com.activeandroid.query.Select in project ActiveAndroid by pardom.
the class CountTest method testCountWhereClauseSql.
/**
* Should be a count with the specified where-clause.
*/
public void testCountWhereClauseSql() {
final String expected = "SELECT COUNT(*) FROM MockModel WHERE intField = ?";
String actual = new Select().from(MockModel.class).where("intField = ?", 1).toCountSql();
assertEquals(expected, actual);
}
use of com.activeandroid.query.Select in project ActiveAndroid by pardom.
the class CountTest method testCountTable.
/**
* Should return the same count as there are entries in the result set/table.
*/
public void testCountTable() {
cleanTable();
populateTable();
From from = new Select().from(MockModel.class);
final List<MockModel> list = from.execute();
final int count = from.count();
assertEquals(3, count);
assertEquals(list.size(), count);
}
use of com.activeandroid.query.Select in project ActiveAndroid by pardom.
the class CountTest method testCountOrderBy.
/**
* Should not change the result if order by is used.
*/
public void testCountOrderBy() {
cleanTable();
populateTable();
From from = new Select().from(MockModel.class).where("intField = ?", 1).orderBy("intField ASC");
final List<MockModel> list = from.execute();
final int count = from.count();
assertEquals(2, count);
assertEquals(list.size(), count);
}
Aggregations