Ejemplo n.º 1
0
  /** Mark expired cards due and update counts. */
  private void checkDue() {
    Log.i(TAG, "Checking due cards...");
    checkDailyStats();

    // Failed cards
    ContentValues val = new ContentValues(1);
    val.put("isDue", 1);

    failedSoonCount +=
        AnkiDb.database.update(
            "cards",
            val,
            "type = 0 and "
                + "isDue = 0 and "
                + "priority in (1,2,3,4) and "
                + String.format(
                    ENGLISH_LOCALE,
                    "combinedDue <= %f",
                    (double) ((System.currentTimeMillis() / 1000.0) + delay0)),
            null);

    failedNowCount =
        (int)
            AnkiDb.queryScalar(
                "SELECT count(id) "
                    + "FROM cards "
                    + "WHERE type = 0 and "
                    + "isDue = 1 and "
                    + String.format(
                        ENGLISH_LOCALE,
                        "combinedDue <= %f",
                        (double) (System.currentTimeMillis() / 1000.0)));

    // Review
    val.clear();
    val.put("isDue", 1);
    revCount +=
        AnkiDb.database.update(
            "cards",
            val,
            "type = 1 and "
                + "isDue = 0 and "
                + "priority in (1,2,3,4) and "
                + String.format(
                    ENGLISH_LOCALE,
                    "combinedDue <= %f",
                    (double) (System.currentTimeMillis() / 1000.0)),
            null);

    // New
    val.clear();
    val.put("isDue", 1);
    newCount +=
        AnkiDb.database.update(
            "cards",
            val,
            "type = 2 and "
                + "isDue = 0 and "
                + "priority in (1,2,3,4) and "
                + String.format(
                    ENGLISH_LOCALE,
                    "combinedDue <= %f",
                    (double) (System.currentTimeMillis() / 1000.0)),
            null);

    newCountToday = Math.max(Math.min(newCount, newCardsPerDay - newCardsToday()), 0);
  }