Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f4903725aa |
No files matched your search
@@ -93,9 +93,7 @@ fn load_old_schema(connection: &Connection) -> Result<ImportData, NotificationDa
|
||||
}
|
||||
Err(IncorrectAnkiFile)
|
||||
}
|
||||
fn load_new_schema(connection: &Connection) -> Result<ImportData, NotificationData> {
|
||||
return Err(IncorrectAnkiFile);
|
||||
}
|
||||
|
||||
pub fn get_words_of_group(
|
||||
connection: &Connection,
|
||||
group_id: u64,
|
||||
@@ -119,3 +117,23 @@ pub fn get_words_of_group(
|
||||
.filter_map(|x| x.ok())
|
||||
.collect::<Vec<ImportNote>>())
|
||||
}
|
||||
|
||||
fn load_new_schema(connection: &Connection) -> Result<ImportData, NotificationData> {
|
||||
return Err(IncorrectAnkiFile);
|
||||
}
|
||||
|
||||
pub struct DeckHeader {
|
||||
pub id: u64,
|
||||
pub name: String,
|
||||
pub count: u64,
|
||||
}
|
||||
|
||||
pub fn load_decks(connection: &Connection) -> Result<Vec<DeckHeader>, NotificationData> {
|
||||
let mut stmt = connection
|
||||
.prepare("select id, name from decks")
|
||||
.unwrap();
|
||||
Ok(stmt.query_map([], |row| Ok(DeckHeader{
|
||||
id: row.get::<usize, i64>(0)? as u64,
|
||||
name: row.get(1)?
|
||||
})).unwrap().filter_map(|x| x.ok()).collect::<Vec<DeckHeader>>())
|
||||
}
|
||||
+17
-1
@@ -1,5 +1,5 @@
|
||||
#[cfg(test)]
|
||||
mod mod_tests {
|
||||
mod data_access {
|
||||
use crate::data::Id;
|
||||
use crate::data::entities::{EntityData, EntityHandle};
|
||||
use crate::data::repositories::fast_position_of;
|
||||
@@ -121,3 +121,19 @@ mod mod_tests {
|
||||
assert_eq!(entity.index(), 0)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod anki_import{
|
||||
use std::path::{Path, PathBuf};
|
||||
use rusqlite::Connection;
|
||||
use crate::data_provider::import::load_decks;
|
||||
use crate::notification::NotificationData::IncorrectAnkiFile;
|
||||
|
||||
#[test]
|
||||
pub fn decks(){
|
||||
let file_name = Path::new("import");
|
||||
let connection = Connection::open(file_name).unwrap();
|
||||
let decks = load_decks(&connection).unwrap();
|
||||
assert_eq!(decks.len(), 2);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user