mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
Rename EaseKind to RatingKind
This commit is contained in:
parent
b0890b0e47
commit
692aa16f6b
5 changed files with 29 additions and 28 deletions
|
@ -36,7 +36,8 @@ use crate::{
|
|||
sched::timespan::{answer_button_time, time_span},
|
||||
search::{
|
||||
concatenate_searches, negate_search, normalize_search, replace_search_term, write_nodes,
|
||||
BoolSeparator, EaseKind, Node, PropertyKind, SearchNode, SortMode, StateKind, TemplateKind,
|
||||
BoolSeparator, Node, PropertyKind, RatingKind, SearchNode, SortMode, StateKind,
|
||||
TemplateKind,
|
||||
},
|
||||
stats::studied_today,
|
||||
sync::{
|
||||
|
@ -355,15 +356,15 @@ impl From<BoolSeparatorProto> for BoolSeparator {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<pb::search_term::Rating> for EaseKind {
|
||||
impl From<pb::search_term::Rating> for RatingKind {
|
||||
fn from(r: pb::search_term::Rating) -> Self {
|
||||
match r {
|
||||
pb::search_term::Rating::Again => EaseKind::AnswerButton(1),
|
||||
pb::search_term::Rating::Hard => EaseKind::AnswerButton(2),
|
||||
pb::search_term::Rating::Good => EaseKind::AnswerButton(3),
|
||||
pb::search_term::Rating::Easy => EaseKind::AnswerButton(4),
|
||||
pb::search_term::Rating::Any => EaseKind::AnyAnswerButton,
|
||||
pb::search_term::Rating::ByReschedule => EaseKind::ManualReschedule,
|
||||
pb::search_term::Rating::Again => RatingKind::AnswerButton(1),
|
||||
pb::search_term::Rating::Hard => RatingKind::AnswerButton(2),
|
||||
pb::search_term::Rating::Good => RatingKind::AnswerButton(3),
|
||||
pb::search_term::Rating::Easy => RatingKind::AnswerButton(4),
|
||||
pb::search_term::Rating::Any => RatingKind::AnyAnswerButton,
|
||||
pb::search_term::Rating::ByReschedule => RatingKind::ManualReschedule,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ mod sqlwriter;
|
|||
mod writer;
|
||||
|
||||
pub use cards::SortMode;
|
||||
pub use parser::{EaseKind, Node, PropertyKind, SearchNode, StateKind, TemplateKind};
|
||||
pub use parser::{Node, PropertyKind, RatingKind, SearchNode, StateKind, TemplateKind};
|
||||
pub use writer::{
|
||||
concatenate_searches, negate_search, normalize_search, replace_search_term, write_nodes,
|
||||
BoolSeparator,
|
||||
|
|
|
@ -58,7 +58,7 @@ pub enum SearchNode<'a> {
|
|||
NoteType(Cow<'a, str>),
|
||||
Rated {
|
||||
days: u32,
|
||||
ease: EaseKind,
|
||||
ease: RatingKind,
|
||||
},
|
||||
Tag(Cow<'a, str>),
|
||||
Duplicates {
|
||||
|
@ -87,7 +87,7 @@ pub enum PropertyKind {
|
|||
Lapses(u32),
|
||||
Ease(f32),
|
||||
Position(u32),
|
||||
Rated(i32, EaseKind),
|
||||
Rated(i32, RatingKind),
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
|
@ -109,7 +109,7 @@ pub enum TemplateKind<'a> {
|
|||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
pub enum EaseKind {
|
||||
pub enum RatingKind {
|
||||
AnswerButton(u8),
|
||||
AnyAnswerButton,
|
||||
ManualReschedule,
|
||||
|
@ -353,7 +353,7 @@ fn parse_flag(s: &str) -> ParseResult<SearchNode> {
|
|||
fn parse_resched(s: &str) -> ParseResult<SearchNode> {
|
||||
parse_u32(s, "resched:").map(|days| SearchNode::Rated {
|
||||
days,
|
||||
ease: EaseKind::ManualReschedule,
|
||||
ease: RatingKind::ManualReschedule,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -392,7 +392,7 @@ fn parse_prop(prop_clause: &str) -> ParseResult<SearchNode> {
|
|||
"rated" => parse_prop_rated(num, prop_clause)?,
|
||||
"resched" => PropertyKind::Rated(
|
||||
parse_negative_i32(num, prop_clause)?,
|
||||
EaseKind::ManualReschedule,
|
||||
RatingKind::ManualReschedule,
|
||||
),
|
||||
"ivl" => PropertyKind::Interval(parse_u32(num, prop_clause)?),
|
||||
"reps" => PropertyKind::Reps(parse_u32(num, prop_clause)?),
|
||||
|
@ -470,9 +470,9 @@ fn parse_i64<'a>(num: &str, context: &'a str) -> ParseResult<'a, i64> {
|
|||
})
|
||||
}
|
||||
|
||||
fn parse_answer_button<'a>(num: Option<&str>, context: &'a str) -> ParseResult<'a, EaseKind> {
|
||||
fn parse_answer_button<'a>(num: Option<&str>, context: &'a str) -> ParseResult<'a, RatingKind> {
|
||||
Ok(if let Some(num) = num {
|
||||
EaseKind::AnswerButton(
|
||||
RatingKind::AnswerButton(
|
||||
num.parse()
|
||||
.map_err(|_| ())
|
||||
.and_then(|n| if matches!(n, 1..=4) { Ok(n) } else { Err(()) })
|
||||
|
@ -487,7 +487,7 @@ fn parse_answer_button<'a>(num: Option<&str>, context: &'a str) -> ParseResult<'
|
|||
})?,
|
||||
)
|
||||
} else {
|
||||
EaseKind::AnyAnswerButton
|
||||
RatingKind::AnyAnswerButton
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright: Ankitects Pty Ltd and contributors
|
||||
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||
|
||||
use super::parser::{EaseKind, Node, PropertyKind, SearchNode, StateKind, TemplateKind};
|
||||
use super::parser::{Node, PropertyKind, RatingKind, SearchNode, StateKind, TemplateKind};
|
||||
use crate::{
|
||||
card::{CardQueue, CardType},
|
||||
collection::Collection,
|
||||
|
@ -211,7 +211,7 @@ impl SqlWriter<'_> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn write_rated(&mut self, op: &str, days: i64, ease: &EaseKind) -> Result<()> {
|
||||
fn write_rated(&mut self, op: &str, days: i64, ease: &RatingKind) -> Result<()> {
|
||||
let today_cutoff = self.col.timing_today()?.next_day_at;
|
||||
let target_cutoff_ms = (today_cutoff + 86_400 * days) * 1_000;
|
||||
let day_before_cutoff_ms = (today_cutoff + 86_400 * (days - 1)) * 1_000;
|
||||
|
@ -240,9 +240,9 @@ impl SqlWriter<'_> {
|
|||
.unwrap();
|
||||
|
||||
match ease {
|
||||
EaseKind::AnswerButton(u) => write!(self.sql, " and ease = {})", u),
|
||||
EaseKind::AnyAnswerButton => write!(self.sql, " and ease > 0)"),
|
||||
EaseKind::ManualReschedule => write!(self.sql, " and ease = 0)"),
|
||||
RatingKind::AnswerButton(u) => write!(self.sql, " and ease = {})", u),
|
||||
RatingKind::AnyAnswerButton => write!(self.sql, " and ease > 0)"),
|
||||
RatingKind::ManualReschedule => write!(self.sql, " and ease = 0)"),
|
||||
}
|
||||
.unwrap();
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ use crate::{
|
|||
decks::DeckID as DeckIDType,
|
||||
err::Result,
|
||||
notetype::NoteTypeID as NoteTypeIDType,
|
||||
search::parser::{parse, EaseKind, Node, PropertyKind, SearchNode, StateKind, TemplateKind},
|
||||
search::parser::{parse, Node, PropertyKind, RatingKind, SearchNode, StateKind, TemplateKind},
|
||||
};
|
||||
use itertools::Itertools;
|
||||
use std::mem;
|
||||
|
@ -154,8 +154,8 @@ fn write_template(template: &TemplateKind) -> String {
|
|||
}
|
||||
}
|
||||
|
||||
fn write_rated(days: &u32, ease: &EaseKind) -> String {
|
||||
use EaseKind::*;
|
||||
fn write_rated(days: &u32, ease: &RatingKind) -> String {
|
||||
use RatingKind::*;
|
||||
match ease {
|
||||
AnswerButton(n) => format!("\"rated:{}:{}\"", days, n),
|
||||
AnyAnswerButton => format!("\"rated:{}\"", days),
|
||||
|
@ -196,9 +196,9 @@ fn write_property(operator: &str, kind: &PropertyKind) -> String {
|
|||
Ease(f) => format!("\"prop:ease{}{}\"", operator, f),
|
||||
Position(u) => format!("\"prop:pos{}{}\"", operator, u),
|
||||
Rated(u, ease) => match ease {
|
||||
EaseKind::AnswerButton(val) => format!("\"prop:rated{}{}:{}\"", operator, u, val),
|
||||
EaseKind::AnyAnswerButton => format!("\"prop:rated{}{}\"", operator, u),
|
||||
EaseKind::ManualReschedule => format!("\"prop:resched{}{}\"", operator, u),
|
||||
RatingKind::AnswerButton(val) => format!("\"prop:rated{}{}:{}\"", operator, u, val),
|
||||
RatingKind::AnyAnswerButton => format!("\"prop:rated{}{}\"", operator, u),
|
||||
RatingKind::ManualReschedule => format!("\"prop:resched{}{}\"", operator, u),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue