From 812fd2cbc286768450a9bdd28dabe1eb5223bec1 Mon Sep 17 00:00:00 2001 From: David Allison <62114487+david-allison@users.noreply.github.com> Date: Tue, 4 Jun 2024 13:53:44 +0100 Subject: [PATCH] chore(card-browser): logs Diagnostics for https://redirect.github.com/ankidroid/Anki-Android/issues/16541 --- .../java/com/ichi2/anki/browser/CardBrowserViewModel.kt | 3 +++ .../src/main/java/com/ichi2/libanki/sched/Scheduler.kt | 8 ++++++-- AnkiDroid/src/test/java/com/ichi2/testutils/JvmTest.kt | 2 +- .../test/java/com/ichi2/testutils/TestChangeSubscriber.kt | 1 + 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/browser/CardBrowserViewModel.kt b/AnkiDroid/src/main/java/com/ichi2/anki/browser/CardBrowserViewModel.kt index 2216f1a92962..c9e08b424370 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/browser/CardBrowserViewModel.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/browser/CardBrowserViewModel.kt @@ -386,12 +386,14 @@ class CardBrowserViewModel( fun selectAll() { if (_selectedRows.addAll(cards.wrapped)) { + Timber.d("selecting all: %d item(s)", cards.wrapped.size) refreshSelectedRowsFlow() } } fun selectNone() { if (_selectedRows.isEmpty()) return + Timber.d("selecting none") _selectedRows.clear() refreshSelectedRowsFlow() } @@ -482,6 +484,7 @@ class CardBrowserViewModel( sched.suspendCards(cardIds).changes } } + Timber.d("finished 'toggleSuspendCards'") } /** diff --git a/AnkiDroid/src/main/java/com/ichi2/libanki/sched/Scheduler.kt b/AnkiDroid/src/main/java/com/ichi2/libanki/sched/Scheduler.kt index 745d003f7b91..dba03fb068ba 100644 --- a/AnkiDroid/src/main/java/com/ichi2/libanki/sched/Scheduler.kt +++ b/AnkiDroid/src/main/java/com/ichi2/libanki/sched/Scheduler.kt @@ -232,8 +232,10 @@ open class Scheduler(val col: Collection) { * @param ids Id of cards to suspend */ open fun suspendCards(ids: Iterable): OpChangesWithCount { + val cids = ids.toList() + Timber.i("suspending %d card(s)", cids.size) return col.backend.buryOrSuspendCards( - cardIds = ids.toList(), + cardIds = cids, noteIds = listOf(), mode = BuryOrSuspendCardsRequest.Mode.SUSPEND ) @@ -251,8 +253,10 @@ open class Scheduler(val col: Collection) { * @param ids Id of cards to unsuspend */ open fun unsuspendCards(ids: Iterable): OpChanges { + val cids = ids.toList() + Timber.i("unsuspending %d card(s)", cids.size) return col.backend.restoreBuriedAndSuspendedCards( - cids = ids.toList() + cids = cids ) } diff --git a/AnkiDroid/src/test/java/com/ichi2/testutils/JvmTest.kt b/AnkiDroid/src/test/java/com/ichi2/testutils/JvmTest.kt index 43718d637d27..fad6d9de71ce 100644 --- a/AnkiDroid/src/test/java/com/ichi2/testutils/JvmTest.kt +++ b/AnkiDroid/src/test/java/com/ichi2/testutils/JvmTest.kt @@ -104,7 +104,7 @@ open class JvmTest : TestClass { Dispatchers.resetMain() runBlocking { CollectionManager.discardBackend() } Timber.uprootAll() - println("""-- executing test "${testName.methodName}"""") + println("""-- completed test "${testName.methodName}"""") } fun assumeThat(actual: T, matcher: Matcher?) { diff --git a/AnkiDroid/src/test/java/com/ichi2/testutils/TestChangeSubscriber.kt b/AnkiDroid/src/test/java/com/ichi2/testutils/TestChangeSubscriber.kt index c48d2309d075..e698a7462092 100644 --- a/AnkiDroid/src/test/java/com/ichi2/testutils/TestChangeSubscriber.kt +++ b/AnkiDroid/src/test/java/com/ichi2/testutils/TestChangeSubscriber.kt @@ -45,6 +45,7 @@ suspend fun ensureOpsExecuted(count: Int, block: suspend () -> Unit) { Timber.d("ChangeManager op detected") changes++ } + Timber.v("Listening for ChangeManager ops") block() // we should be fine to not cleanup here, as the subscriber goes out of scope assertThat("ChangeManager: expected $count calls", changes, equalTo(count))