Skip to content

Commit

Permalink
Remove setReportLimit()
Browse files Browse the repository at this point in the history
It was introduced due to ankidroid#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.
  • Loading branch information
dae committed Jul 23, 2022
1 parent 724c292 commit 739099b
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 49 deletions.
12 changes: 0 additions & 12 deletions AnkiDroid/src/main/java/com/ichi2/libanki/Collection.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<String?> = ArrayList()
var cardsWithFixedHomeDeckCount = 0
Expand Down
11 changes: 0 additions & 11 deletions AnkiDroid/src/main/java/com/ichi2/libanki/sched/AbstractSched.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -441,12 +436,6 @@ abstract class AbstractSched(val col: Collection) {
*/
abstract fun setContext(contextReference: WeakReference<Activity>)

/**
* 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.
*
Expand Down
7 changes: 1 addition & 6 deletions AnkiDroid/src/main/java/com/ichi2/libanki/sched/SchedV2.java
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ public List<TreeNode<DeckDueTreeNode>> deckDueTree(@Nullable CancelListener canc
if (!BackendFactory.getDefaultLegacySchema()) {
return BackendSchedKt.deckTreeLegacy(getCol().getNewBackend(), true);
} else {
_checkDay();
List<DeckDueTreeNode> allDecksSorted = deckDueList(cancelListener);
if (allDecksSorted == null) {
return null;
Expand Down Expand Up @@ -3116,12 +3117,6 @@ public void setContext(@Nullable WeakReference<Activity> 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
Expand Down
22 changes: 4 additions & 18 deletions AnkiDroid/src/main/java/com/ichi2/libanki/sync/Syncer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down Expand Up @@ -105,7 +98,6 @@ class Syncer(
fun sync(con: Connection): Pair<ConnectionResultType, Any?>? {
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()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
}
2 changes: 0 additions & 2 deletions AnkiDroid/src/main/java/com/ichi2/widget/WidgetStatus.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down

0 comments on commit 739099b

Please sign in to comment.