Cleanup and format
This commit is contained in:
1 parent
af6cf10765
commit
d5a2a575fe
9 files changed
+64
-73
No files matched your search
+2
-26
@@ -1,10 +1,9 @@
|
||||
use crate::app::AppState;
|
||||
use crate::core::srs::{FADE_PER_DAY, MAX_SCORE, OrderMode, WordOpenMode};
|
||||
use crate::data::{INVALID_ID, Id};
|
||||
use chrono::{DateTime, Local, NaiveDate, Utc};
|
||||
use fsrs::{FSRS, MemoryState};
|
||||
use chrono::{DateTime, NaiveDate, Utc};
|
||||
use fsrs::MemoryState;
|
||||
use log::info;
|
||||
use rand::{RngExt, random, rng};
|
||||
use rayon::prelude::*;
|
||||
use rhai::{Engine, Scope};
|
||||
use std::collections::HashMap;
|
||||
@@ -162,29 +161,6 @@ impl CardStatistics {
|
||||
self.last_open = Utc::now();
|
||||
}
|
||||
|
||||
pub fn update_fsrs(&mut self, status: WordOpenMode, by_fsrs: bool, fsrs: FSRS)
|
||||
{
|
||||
let today = Local::now().date_naive().to_epoch_days();
|
||||
let written = self.fsrs_opened.to_epoch_days();
|
||||
let memory = fsrs
|
||||
.next_states(self.fsrs_memory, 0.9, (today - written) as u32)
|
||||
.expect("Wrong next stage calculation");
|
||||
let next = match status {
|
||||
WordOpenMode::Easy => memory.easy,
|
||||
WordOpenMode::Ok => memory.good,
|
||||
WordOpenMode::Hard => memory.hard,
|
||||
WordOpenMode::None => memory.again,
|
||||
};
|
||||
|
||||
let mut next_day = today + next.interval.round() as i32;
|
||||
if next_day - today >= 5 {
|
||||
let offset = ((rng().random::<f32>() - 0.5) * 3.0).round() as i32;
|
||||
next_day += offset;
|
||||
}
|
||||
self.fsrs_memory = Some(next.memory);
|
||||
self.fsrs_open_day = NaiveDate::from_epoch_days(next_day).unwrap();
|
||||
self.fsrs_opened = self.last_open.date_naive();
|
||||
}
|
||||
pub fn calculated_score(&self) -> f32 {
|
||||
let time = Utc::now() - self.last_open;
|
||||
let days = time.num_days();
|
||||
|
||||
Reference in new issue
Block a user