Fix deck data collecting
This commit is contained in:
1 parent
c5e91b844c
commit
3f43676580
4 files changed
+63
-22
No files matched your search
+11
-10
@@ -26,7 +26,7 @@ const MAX_HISTORY_LEN: usize = 20;
|
||||
const MAX_HISTORY_LEN_PART: f32 = 0.33;
|
||||
const MAX_SCORE: u8 = 25;
|
||||
const FADE_PER_DAY: f32 = 0.95;
|
||||
#[derive(Clone, PartialEq, Eq, Debug, Hash, Copy)]
|
||||
#[derive(Clone, PartialEq, Eq, Debug, Hash, Copy, Ord, PartialOrd)]
|
||||
pub struct Id(u32);
|
||||
pub const INVALID_ID: Id = Id(0);
|
||||
impl FromStr for Id {
|
||||
@@ -69,6 +69,12 @@ impl ToSql for Id {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Id> for String {
|
||||
fn from(value: Id) -> Self {
|
||||
value.0.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
impl Id {
|
||||
pub(crate) fn is_valid(self) -> bool {
|
||||
self.0 != 0
|
||||
@@ -357,17 +363,12 @@ impl DeckData {
|
||||
let state_for = state.clone();
|
||||
let state_locked = state.lock();
|
||||
|
||||
let mut current_set = load_stats_of_deck(settings, &state_locked.connection);
|
||||
let last_list: Vec<_> = settings
|
||||
.get_word_list(&state_locked)
|
||||
.iter()
|
||||
.map(|w| &state_locked.dictionary[*w])
|
||||
.cloned()
|
||||
.collect();
|
||||
let stats = load_stats_of_deck(settings, &state_locked.connection);
|
||||
let words = stats.iter().map(|stat| state_locked.dictionary.binary_search_by_key(&stat.word_id, |w| w.id).unwrap()).map(|index| &state_locked.dictionary[index]).cloned().collect();
|
||||
|
||||
Self {
|
||||
set: current_set,
|
||||
words: last_list,
|
||||
set: stats,
|
||||
words,
|
||||
current_word_index: None,
|
||||
state: state_for,
|
||||
order_module: match settings.open_mode {
|
||||
|
||||
Reference in new issue
Block a user