Visual changes

This commit is contained in:
2026-08-01 23:40:56 +03:00
parent 20cb50574c
commit 64fbfb5a32
10 changed files with 55 additions and 68 deletions
+19 -19
View File
@@ -64,29 +64,29 @@ pub fn add_stat_list(stat: &mut Vec<CardStatistics>, connection: &Connection) {
let mut index = 0;
for id in start_index..=last_index {
stat[index].id = id as u32;
stat[index].id = id;
index += 1;
}
}
pub fn add_stat(stat: &mut CardStatistics, connection: &Connection) {
let time = Instant::now();
let index = connection
.query_row(
"INSERT INTO card_stats (word_id, set_id, score, last_opened) VALUES (?1, ?2, ?3, ?4) RETURNING id",
(
&stat.word_id,
&stat.set_id,
&stat.score,
&stat.last_open.timestamp(),
),
|row| row.get(0)
)
.unwrap_or_else(|e| {println!("{}", e); 0});
stat.id = index;
println!("Added stat: {}", time.elapsed().as_millis());
}
// pub fn add_stat(stat: &mut CardStatistics, connection: &Connection) {
// let time = Instant::now();
// let index = connection
// .query_row(
// "INSERT INTO card_stats (word_id, set_id, score, last_opened) VALUES (?1, ?2, ?3, ?4) RETURNING id",
// (
// &stat.word_id,
// &stat.set_id,
// &stat.score,
// &stat.last_open.timestamp(),
// ),
// |row| row.get(0)
// )
// .unwrap_or_else(|e| {println!("{}", e); 0});
//
// stat.id = index;
// println!("Added stat: {}", time.elapsed().as_millis());
// }
pub fn update_stat_score(stat: &CardStatistics, connection: &Connection) {
let time = Instant::now();
+1 -5
View File
@@ -6,17 +6,13 @@ use std::io::Write;
use std::io::{BufRead, BufReader};
use std::path::PathBuf;
const MAX_HISTORY_LENGTH: usize = 1000;
pub fn get_history_of_set(id: u32) -> Vec<HistoryItem> {
let app_dir = app_data_dir();
let head = app_dir.clone().join(format!("set_{}_history.csv", id));
let tail = app_dir.clone().join(format!("set_{}_history_tail.csv", id));
let mut lines = Vec::new();
append_lines_if_exists(tail, &mut lines);
append_lines_if_exists(head, &mut lines);
lines.reverse();
parse_history_items(lines)
}
+1 -1
View File
@@ -17,7 +17,7 @@ pub fn create_db() {
}
}
fn ensure_db_schema(conn: &Connection) {}
fn ensure_db_schema(_: &Connection) {}
fn create_tables(conn: &Connection) {
make_card_set(conn).unwrap();