From 2798fcc9960b07f5fabb71ee780be92a78e97e8a Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Fri, 8 Jul 2022 14:39:03 +1000 Subject: [PATCH] Remove setReportLimit() It was introduced due to #5666, but AnkiWeb has ignored the due counts in the sanity check for about 18 months, so this is no longer necessary. Also remove _updateCutoff() and _checkDay() from the public API. --- .../main/java/com/ichi2/libanki/Collection.kt | 12 ---------- .../com/ichi2/libanki/sched/AbstractSched.kt | 11 ---------- .../java/com/ichi2/libanki/sched/SchedV2.java | 7 +----- .../java/com/ichi2/libanki/sync/Syncer.kt | 22 ++++--------------- .../java/com/ichi2/widget/WidgetStatus.kt | 2 -- 5 files changed, 5 insertions(+), 49 deletions(-) diff --git a/AnkiDroid/src/main/java/com/ichi2/libanki/Collection.kt b/AnkiDroid/src/main/java/com/ichi2/libanki/Collection.kt index 9e55f9996c6b..ff2a7f960213 100644 --- a/AnkiDroid/src/main/java/com/ichi2/libanki/Collection.kt +++ b/AnkiDroid/src/main/java/com/ichi2/libanki/Collection.kt @@ -2558,18 +2558,6 @@ open class Collection( } } - // This duplicates _loadScheduler (but returns the value and sets the report limit). - fun createScheduler(reportLimit: Int): AbstractSched? { - val ver = schedVer() - if (ver == 1) { - sched = Sched(this) - } else if (ver == 2) { - sched = SchedV2(this) - } - sched.setReportLimit(reportLimit) - return sched - } - class CheckDatabaseResult(private val oldSize: Long) { private val mProblems: MutableList = ArrayList() var cardsWithFixedHomeDeckCount = 0 diff --git a/AnkiDroid/src/main/java/com/ichi2/libanki/sched/AbstractSched.kt b/AnkiDroid/src/main/java/com/ichi2/libanki/sched/AbstractSched.kt index fec2be30b21b..ee3a501fa30e 100644 --- a/AnkiDroid/src/main/java/com/ichi2/libanki/sched/AbstractSched.kt +++ b/AnkiDroid/src/main/java/com/ichi2/libanki/sched/AbstractSched.kt @@ -57,9 +57,6 @@ abstract class AbstractSched(val col: Collection) { // Should ideally be protected. It's public only because CollectionTask should call it when the scheduler planned this task abstract fun reset() - /** Check whether we are a new day, and update if so. */ - abstract fun _updateCutoff() - /** Ensure that the question on the potential next card can be accessed quickly. */ abstract fun preloadNextCard() @@ -250,8 +247,6 @@ abstract class AbstractSched(val col: Collection) { // In this abstract class for testing purpose only abstract fun _cardConf(card: Card): DeckConfig - abstract fun _checkDay() - /** * @param context Some Context to access the lang * @return A message to show to user when they reviewed the last card. Let them know if they can see learning card later today @@ -441,12 +436,6 @@ abstract class AbstractSched(val col: Collection) { */ abstract fun setContext(contextReference: WeakReference) - /** - * Change the maximal number shown in counts. - * @param reportLimit A maximal number of cards added in the queue at once. - */ - abstract fun setReportLimit(reportLimit: Int) - /** * Reverts answering a card. * diff --git a/AnkiDroid/src/main/java/com/ichi2/libanki/sched/SchedV2.java b/AnkiDroid/src/main/java/com/ichi2/libanki/sched/SchedV2.java index 471037ec2332..d20cfbe80d9f 100644 --- a/AnkiDroid/src/main/java/com/ichi2/libanki/sched/SchedV2.java +++ b/AnkiDroid/src/main/java/com/ichi2/libanki/sched/SchedV2.java @@ -583,6 +583,7 @@ public List> deckDueTree(@Nullable CancelListener canc if (!BackendFactory.getDefaultLegacySchema()) { return BackendSchedKt.deckTreeLegacy(getCol().getNewBackend(), true); } else { + _checkDay(); List allDecksSorted = deckDueList(cancelListener); if (allDecksSorted == null) { return null; @@ -3116,12 +3117,6 @@ public void setContext(@Nullable WeakReference contextReference) { mContextReference = contextReference; } - /** not in libAnki. Added due to #5666: inconsistent selected deck card counts on sync */ - @Override - public void setReportLimit(int reportLimit) { - this.mReportLimit = reportLimit; - } - @Override public void undoReview(@NonNull Card oldCardData, boolean wasLeech) { // remove leech tag if it didn't have it before diff --git a/AnkiDroid/src/main/java/com/ichi2/libanki/sync/Syncer.kt b/AnkiDroid/src/main/java/com/ichi2/libanki/sync/Syncer.kt index deec8efea453..fa37c709b361 100644 --- a/AnkiDroid/src/main/java/com/ichi2/libanki/sync/Syncer.kt +++ b/AnkiDroid/src/main/java/com/ichi2/libanki/sync/Syncer.kt @@ -27,13 +27,8 @@ import com.ichi2.anki.analytics.UsageAnalytics.sendAnalyticsEvent import com.ichi2.anki.exception.UnknownHttpResponseException import com.ichi2.async.Connection import com.ichi2.async.Connection.Companion.isCancelled +import com.ichi2.libanki.* import com.ichi2.libanki.Collection -import com.ichi2.libanki.Consts -import com.ichi2.libanki.DB -import com.ichi2.libanki.Deck -import com.ichi2.libanki.DeckConfig -import com.ichi2.libanki.Model -import com.ichi2.libanki.Utils import com.ichi2.libanki.sched.AbstractDeckTreeNode import com.ichi2.libanki.sync.Syncer.ConnectionResultType.* import com.ichi2.libanki.utils.TimeManager.time @@ -44,9 +39,7 @@ import com.ichi2.utils.JSONObject import com.ichi2.utils.KotlinCleanup import timber.log.Timber import java.io.IOException -import java.util.Arrays -import java.util.LinkedList -import kotlin.collections.ArrayList +import java.util.* @KotlinCleanup("IDE-lint") class Syncer( @@ -105,7 +98,6 @@ class Syncer( fun sync(con: Connection): Pair? { syncMsg = "" // if the deck has any pending changes, flush them first and bump mod time - col.sched._updateCutoff() col.save() // step 1: login & metadata val ret = remoteServer.meta() @@ -405,11 +397,8 @@ class Syncer( val check = JSONArray() val counts = JSONArray() - // #5666 - not in libAnki - // We modified mReportLimit inside the scheduler, and this causes issues syncing dynamic decks. - val syncScheduler = col.createScheduler(SYNC_SCHEDULER_REPORT_LIMIT) - syncScheduler!!.resetCounts() - val counts_ = syncScheduler.counts() + col.sched.resetCounts() + val counts_ = col.sched.counts() @KotlinCleanup("apply{}") counts.put(counts_.new) counts.put(counts_.lrn) @@ -862,8 +851,5 @@ class Syncer( const val TYPE_FLOAT = 2 const val TYPE_STRING = 3 const val TYPE_BLOB = 4 - - /** The libAnki value of `sched.mReportLimit` */ - private const val SYNC_SCHEDULER_REPORT_LIMIT = 1000 } } diff --git a/AnkiDroid/src/main/java/com/ichi2/widget/WidgetStatus.kt b/AnkiDroid/src/main/java/com/ichi2/widget/WidgetStatus.kt index 01dd0825e3b9..3dc5b8e1c74a 100644 --- a/AnkiDroid/src/main/java/com/ichi2/widget/WidgetStatus.kt +++ b/AnkiDroid/src/main/java/com/ichi2/widget/WidgetStatus.kt @@ -101,8 +101,6 @@ object WidgetStatus { private fun updateCounts(context: Context) { val total = Counts() val col = CollectionHelper.getInstance().getCol(context) - // Ensure queues are reset if we cross over to the next day. - col.sched._checkDay() // Only count the top-level decks in the total val nodes = col.sched.deckDueTree().map { it.value }