This commit is contained in:
2026-05-05 12:06:17 +03:00
parent 9cb034066e
commit 99991a67a7
9 changed files with 17 additions and 42 deletions
-22
View File
@@ -39,28 +39,6 @@ pub fn add_stat(stat: &mut CardStatistics, connection: &Connection) {
stat.id = index;
}
pub fn update_stat(stat: &mut CardStatistics, connection: &Connection){
if stat.id == 0 {
add_stat(stat, &connection);
}
else {
connection
.execute(
"UPDATE card_stats SET word_id = ?1, set_id = ?2, score = ?3, last_opened = ?4 WHERE id = ?5",
(
&stat.word_id,
&stat.set_id,
&stat.score,
&stat.last_open,
&stat.id
),
)
.unwrap_or_else(|e| {println!("{}", e); 0});
}
}
pub fn update_stat_score(stat: &CardStatistics, connection: &Connection){
connection
.execute(
+1 -2
View File
@@ -1,9 +1,8 @@
use crate::dictionary::app_data_dir;
use rodio::Decoder;
use reqwest::Client;
use sha2::{Digest, Sha256};
use std::fs::File;
use std::io::BufReader;
use reqwest::Client;
pub async fn get_voice(text: &str) -> BufReader<File> {
let mut path = app_data_dir();
+2 -2
View File
@@ -124,13 +124,13 @@ pub fn load_words(connection: &Connection) -> Vec<WordData> {
.unwrap();
let word_iter = stmt
.query_map([], |row| {
let addinionals: String = row.get(4)?;
let additional: String = row.get(4)?;
Ok(WordData {
id: row.get(0)?,
key: row.get(1)?,
value: row.get(2)?,
tags: row.get(3)?,
additional: serde_json::from_str::<HashMap<String, String>>(&addinionals).unwrap(),
additional: serde_json::from_str::<HashMap<String, String>>(&additional).unwrap(),
group_id: row.get(5)?,
})
})