0
0
mirror of https://github.com/ankidroid/Anki-Android.git synced 2024-09-20 03:52:15 +02:00

port parent limit change from desktop

5f9792392a
This commit is contained in:
Damien Elmes 2021-03-02 11:47:28 +10:00 committed by Mike Hardy
parent 4e84ce3c6d
commit e1e01a7cc9
2 changed files with 5 additions and 15 deletions

View File

@ -1546,17 +1546,7 @@ public class SchedV2 extends AbstractSched {
lim--; lim--;
} }
if (parentLimit != null) { return lim;
return Math.min(parentLimit, lim);
} else if (!d.getString("name").contains("::")) {
return lim;
} else {
for (@NonNull Deck parent : mCol.getDecks().parents(did)) {
// pass in dummy parentLimit so we don't do parent lookup again
lim = Math.min(lim, _deckRevLimitSingle(parent, lim, considerCurrentCard));
}
return lim;
}
} }

View File

@ -782,21 +782,21 @@ public class SchedV2Test extends RobolectricTest {
// (('parent', 1514457677462, 5, 0, 0, (('child', 1514457677463, 5, 0, 0, ()),))) // (('parent', 1514457677462, 5, 0, 0, (('child', 1514457677463, 5, 0, 0, ()),)))
assertEquals("parent", tree.getFullDeckName()); assertEquals("parent", tree.getFullDeckName());
assertEquals(5, tree.getRevCount()); // paren, tree.review_count)t assertEquals(5, tree.getRevCount()); // paren, tree.review_count)t
assertEquals(5, tree.getChildren().get(0).getRevCount()); assertEquals(10, tree.getChildren().get(0).getRevCount());
// .counts() should match // .counts() should match
col.getDecks().select(child.getLong("id")); col.getDecks().select(child.getLong("id"));
col.reset(); col.reset();
assertEquals(new Counts(0, 0, 5), col.getSched().counts()); assertEquals(new Counts(0, 0, 10), col.getSched().counts());
// answering a card in the child should decrement parent count // answering a card in the child should decrement parent count
Card c = getCard(); Card c = getCard();
col.getSched().answerCard(c, 3); col.getSched().answerCard(c, 3);
assertEquals(new Counts(0, 0, 4), col.getSched().counts()); assertEquals(new Counts(0, 0, 9), col.getSched().counts());
tree = col.getSched().deckDueTree().get(1); tree = col.getSched().deckDueTree().get(1);
assertEquals(4, tree.getRevCount()); assertEquals(4, tree.getRevCount());
assertEquals(4, tree.getChildren().get(0).getRevCount()); assertEquals(9, tree.getChildren().get(0).getRevCount());
} }