Add history table and modify card_stats

This commit is contained in:
micialware committed 2026-08-28 17:44:14 +03:00
1 parent 1f3ad22e05
commit 663fa377b1
6 files changed
+153 -5

No files matched your search

+6 -1
View File
@@ -4,11 +4,16 @@ use crate::data::entities::HistoryItem;
use crate::fs::*;
use crate::notification::NotificationData::PermissionDenied;
use crate::notification::{MaybeError, NotificationData};
use chrono::DateTime;
use chrono::{DateTime, NaiveDate};
use std::fs::{File, OpenOptions};
use std::io::Write;
use std::io::{BufRead, BufReader};
use std::path::PathBuf;
use rusqlite::Connection;
pub fn get_open_count_of_set(id: Id, connection: &Connection) -> Result<Vec<(NaiveDate, u32)>, NotificationData>{
todo!()
}
pub fn get_history_of_set(id: Id) -> Result<Vec<HistoryItem>, NotificationData> {
let app_dir = history_dir()?;
+7
View File
@@ -20,6 +20,7 @@ fn create_tables(conn: &Connection) {
make_word_group(conn).expect("Failed to init table");
make_words(conn).expect("Failed to init table");
make_card_stats(conn).expect("Failed to init table");
make_history(conn).expect("Failed to init table");
}
fn make_settings(conn: &Connection) -> Result<(), rusqlite::Error> {
@@ -51,6 +52,12 @@ fn make_card_stats(conn: &Connection) -> Result<(), rusqlite::Error> {
Ok(())
}
fn make_history(conn: &Connection) -> Result<(), rusqlite::Error> {
let query = include_str!("../../sql/history.sql");
conn.execute(query, ())?;
Ok(())
}
pub fn default_connection() -> Connection {
let db_file = db_path();
let connection = Connection::open(db_file).expect("Failed to open database");