no need to log card resets when exporting

This commit is contained in:
Damien Elmes 2021-01-05 11:07:09 +10:00
parent 83136d2491
commit dad4c76089
4 changed files with 16 additions and 9 deletions

View file

@ -1408,7 +1408,7 @@ and (queue={QUEUE_TYPE_NEW} or (queue={QUEUE_TYPE_REV} and due<=?))""",
def schedule_cards_as_new(self, card_ids: List[int]) -> None:
"Put cards at the end of the new queue."
self.col.backend.schedule_cards_as_new(card_ids)
self.col.backend.schedule_cards_as_new(card_ids=card_ids, log=True)
def schedule_cards_as_reviews(
self, card_ids: List[int], min_interval: int, max_interval: int
@ -1432,8 +1432,7 @@ and (queue={QUEUE_TYPE_NEW} or (queue={QUEUE_TYPE_REV} and due<=?))""",
" where id in %s" % sids
)
# and forget any non-new cards, changing their due numbers
self.forgetCards(nonNew)
self.col.log(ids)
self.col.backend.schedule_cards_as_new(card_ids=nonNew, log=False)
# legacy

View file

@ -105,7 +105,7 @@ service BackendService {
rpc EmptyFilteredDeck (DeckID) returns (Empty);
rpc RebuildFilteredDeck (DeckID) returns (UInt32);
rpc ScheduleCardsAsReviews (ScheduleCardsAsReviewsIn) returns (Empty);
rpc ScheduleCardsAsNew (CardIDs) returns (Empty);
rpc ScheduleCardsAsNew (ScheduleCardsAsNewIn) returns (Empty);
rpc SortCards (SortCardsIn) returns (Empty);
rpc SortDeck (SortDeckIn) returns (Empty);
@ -1068,6 +1068,11 @@ message ScheduleCardsAsReviewsIn {
uint32 max_interval = 3;
}
message ScheduleCardsAsNewIn {
repeated int64 card_ids = 1;
bool log = 2;
}
message SortCardsIn {
repeated int64 card_ids = 1;
uint32 starting_from = 2;

View file

@ -565,10 +565,11 @@ impl BackendService for Backend {
})
}
fn schedule_cards_as_new(&self, input: pb::CardIDs) -> BackendResult<Empty> {
fn schedule_cards_as_new(&self, input: pb::ScheduleCardsAsNewIn) -> BackendResult<Empty> {
self.with_col(|col| {
col.reschedule_cards_as_new(&input.into_native())
.map(Into::into)
let cids: Vec<_> = input.card_ids.into_iter().map(CardID).collect();
let log = input.log;
col.reschedule_cards_as_new(&cids, log).map(Into::into)
})
}

View file

@ -68,7 +68,7 @@ impl NewCardSorter {
}
impl Collection {
pub fn reschedule_cards_as_new(&mut self, cids: &[CardID]) -> Result<()> {
pub fn reschedule_cards_as_new(&mut self, cids: &[CardID], log: bool) -> Result<()> {
let usn = self.usn()?;
let mut position = self.get_next_card_position();
self.transact(None, |col| {
@ -76,7 +76,9 @@ impl Collection {
let cards = col.storage.all_searched_cards_in_search_order()?;
for mut card in cards {
let original = card.clone();
col.log_manually_scheduled_review(&card, usn, 0)?;
if log {
col.log_manually_scheduled_review(&card, usn, 0)?;
}
card.schedule_as_new(position);
col.update_card(&mut card, &original, usn)?;
position += 1;