Code cleanup

This commit is contained in:
micialware committed 2026-09-09 15:00:52 +03:00
1 parent 1ad991667b
commit f66bf69ef5
32 files changed
+234 -899

No files matched your search

+7 -13
View File
@@ -1,5 +1,6 @@
use crate::core::srs::{FADE_PER_DAY, MAX_SCORE, WordOpenMode};
use crate::data::{INVALID_ID, Id};
use crate::data_provider::history::HistoryRepositoryInner;
use chrono::{DateTime, Local, NaiveDate, Utc};
use fsrs::MemoryState;
use litemap::LiteMap;
@@ -10,7 +11,6 @@ use std::hash::{Hash, Hasher};
use std::marker::PhantomData;
use std::sync::Arc;
use std::time::Instant;
use crate::data_provider::history::{HistoryRepository, HistoryRepositoryInner};
#[derive(Clone, Debug)]
pub struct WordData {
@@ -70,7 +70,7 @@ pub struct HistoryNote {
pub answer: WordOpenMode,
pub before: u8,
pub after: u8,
pub fsrs: bool
pub fsrs: bool,
}
impl EntityData for HistoryNote {
@@ -86,17 +86,16 @@ impl EntityData for HistoryNote {
impl HistoryRepositoryInner {
pub fn activity_of_deck(&self, id: Id) -> Vec<(NaiveDate, u32)> {
let mut query = self.query(Arc::new(move |note| note.deck_id == id));
let values = query.iter(&self).collect::<Vec<_>>();
let values = query.iter(self).collect::<Vec<_>>();
let mut counts = vec![];
if !values.is_empty() {
let mut date = values[0].timestamp.with_timezone(&Local).date_naive();
let mut count = 0;
for note in values {
let current_date = note.timestamp.with_timezone(&Local).date_naive();
if date == current_date{
if date == current_date {
count += 1;
}
else {
} else {
counts.push((date, count));
date = current_date;
count = 0;
@@ -209,14 +208,9 @@ pub struct EntityHandle<E> {
}
impl<T> Clone for EntityHandle<T> {
fn clone(&self) -> Self {
EntityHandle {
id: self.id,
index: self.index,
_phantom: Default::default(),
}
}
fn clone(&self) -> Self { *self }
}
impl<T> Copy for EntityHandle<T> {}
impl<T> EntityHandle<T> {
pub fn new(id: Id, index: usize, real: bool) -> Self {