Fix filtered deck ordering of intraday learning cards and reviews (#2828)
* Fix filtered deck ordering of intraday learning cards and reviews * Handle rollover correctly
This commit is contained in:
parent
390935d4ea
commit
d752a43e2a
@ -121,7 +121,7 @@ impl Collection {
|
|||||||
format!("({})", term.search)
|
format!("({})", term.search)
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
let order = order_and_limit_for_search(term, ctx.today);
|
let order = order_and_limit_for_search(term, ctx.today, TimestampSecs::now().0);
|
||||||
|
|
||||||
for mut card in self.all_cards_for_search_in_order(&search, SortMode::Custom(order))? {
|
for mut card in self.all_cards_for_search_in_order(&search, SortMode::Custom(order))? {
|
||||||
let original = card.clone();
|
let original = card.clone();
|
||||||
|
@ -5,7 +5,11 @@ use crate::card::CardQueue;
|
|||||||
use crate::decks::FilteredSearchOrder;
|
use crate::decks::FilteredSearchOrder;
|
||||||
use crate::decks::FilteredSearchTerm;
|
use crate::decks::FilteredSearchTerm;
|
||||||
|
|
||||||
pub(crate) fn order_and_limit_for_search(term: &FilteredSearchTerm, today: u32) -> String {
|
pub(crate) fn order_and_limit_for_search(
|
||||||
|
term: &FilteredSearchTerm,
|
||||||
|
today: u32,
|
||||||
|
current_timestamp: i64,
|
||||||
|
) -> String {
|
||||||
let temp_string;
|
let temp_string;
|
||||||
let order = match term.order() {
|
let order = match term.order() {
|
||||||
FilteredSearchOrder::OldestReviewedFirst => "(select max(id) from revlog where cid=c.id)",
|
FilteredSearchOrder::OldestReviewedFirst => "(select max(id) from revlog where cid=c.id)",
|
||||||
@ -15,7 +19,11 @@ pub(crate) fn order_and_limit_for_search(term: &FilteredSearchTerm, today: u32)
|
|||||||
FilteredSearchOrder::Lapses => "lapses desc",
|
FilteredSearchOrder::Lapses => "lapses desc",
|
||||||
FilteredSearchOrder::Added => "n.id, c.ord",
|
FilteredSearchOrder::Added => "n.id, c.ord",
|
||||||
FilteredSearchOrder::ReverseAdded => "n.id desc",
|
FilteredSearchOrder::ReverseAdded => "n.id desc",
|
||||||
FilteredSearchOrder::Due => "c.due, c.ord",
|
FilteredSearchOrder::Due => {
|
||||||
|
temp_string = format!(
|
||||||
|
"(case when c.due > 1000000000 then due else (due - {today}) * 86400 + {current_timestamp} end), c.ord");
|
||||||
|
&temp_string
|
||||||
|
}
|
||||||
FilteredSearchOrder::DuePriority => {
|
FilteredSearchOrder::DuePriority => {
|
||||||
temp_string = format!(
|
temp_string = format!(
|
||||||
"
|
"
|
||||||
|
Loading…
Reference in New Issue
Block a user