Search in sources :

Example 56 with Select

use of com.activeandroid.query.Select in project ActiveAndroid by pardom.

the class SelectTest method testSelectAll.

public void testSelectAll() {
    assertSqlEquals("SELECT ALL * ", new Select().all());
    assertSqlEquals("SELECT ALL * ", new Select().distinct().all());
}
Also used : Select(com.activeandroid.query.Select)

Example 57 with Select

use of com.activeandroid.query.Select in project xDrip by NightscoutFoundation.

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();
}
Also used : Select(com.activeandroid.query.Select)

Example 58 with Select

use of com.activeandroid.query.Select in project xDrip by NightscoutFoundation.

the class PenData method getMissingIndex.

public static long getMissingIndex(final String mac) {
    if (mac == null)
        return -1;
    final List<PenData> list = new Select().from(PenData.class).where("pen_mac = ?", mac).where("timestamp > ?", JoH.tsl() - Constants.WEEK_IN_MS).orderBy("idx desc").execute();
    long got = -1;
    for (final PenData pd : list) {
        if (got != -1 && pd.index != got - 1) {
            UserError.Log.d(TAG, "Tripped missing index on: " + got + " vs " + pd.index);
            return got - 1;
        }
        got = pd.index;
    }
    return -1;
}
Also used : Select(com.activeandroid.query.Select)

Example 59 with Select

use of com.activeandroid.query.Select in project xDrip by NightscoutFoundation.

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;
}
Also used : SharedPreferences(android.content.SharedPreferences) Select(com.activeandroid.query.Select)

Example 60 with Select

use of com.activeandroid.query.Select in project xDrip by NightscoutFoundation.

the class DBSearchUtil method noReadingsInRange.

public static int noReadingsInRange(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"));
    double low = Double.parseDouble(settings.getString("lowValue", "70"));
    if (!mgdl) {
        high *= Constants.MMOLL_TO_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 <= " + high).where("calculated_value >= " + low).where("snyced == 0").count();
    Log.d("DrawStats", "In count: " + count);
    return count;
}
Also used : SharedPreferences(android.content.SharedPreferences) Select(com.activeandroid.query.Select) BgReading(com.eveningoutpost.dexdrip.Models.BgReading)

Aggregations

Select (com.activeandroid.query.Select)80 SharedPreferences (android.content.SharedPreferences)14 From (com.activeandroid.query.From)11 MockModel (com.activeandroid.test.MockModel)11 DecimalFormat (java.text.DecimalFormat)8 ArrayList (java.util.ArrayList)7 Date (java.util.Date)7 Cursor (android.database.Cursor)6 ActiveBluetoothDevice (com.eveningoutpost.dexdrip.Models.ActiveBluetoothDevice)6 JSONException (org.json.JSONException)5 GsonBuilder (com.google.gson.GsonBuilder)4 PendingIntent (android.app.PendingIntent)2 BluetoothDevice (android.bluetooth.BluetoothDevice)2 Intent (android.content.Intent)2 Update (com.activeandroid.query.Update)2 BgReading (com.eveningoutpost.dexdrip.Models.BgReading)2 MissedReadingService (com.eveningoutpost.dexdrip.Services.MissedReadingService)2 Gson (com.google.gson.Gson)2 DateTypeAdapter (com.google.gson.internal.bind.DateTypeAdapter)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2