aboutsummaryrefslogtreecommitdiff
path: root/src/model
diff options
context:
space:
mode:
authorJoris2022-11-27 15:38:39 +0100
committerJoris2022-11-27 15:38:39 +0100
commitd3fb69cf129fe70c932a5d82fdd1bcc613544b5b (patch)
tree6a098c7900f96791489b8548979fb71ccea03e59 /src/model
parent765ba94cdd65184bd4b443c3a946d0d96dc805d6 (diff)
downloadflashcards-d3fb69cf129fe70c932a5d82fdd1bcc613544b5b.tar.gz
flashcards-d3fb69cf129fe70c932a5d82fdd1bcc613544b5b.tar.bz2
flashcards-d3fb69cf129fe70c932a5d82fdd1bcc613544b5b.zip
Speed up deck synchronization
Apply changes for what has been inserted, updated, removed. Also use transactions to speed up multi-writing.
Diffstat (limited to 'src/model')
-rw-r--r--src/model/card.rs9
-rw-r--r--src/model/entry.rs5
-rw-r--r--src/model/mod.rs30
3 files changed, 28 insertions, 16 deletions
diff --git a/src/model/card.rs b/src/model/card.rs
deleted file mode 100644
index 811f877..0000000
--- a/src/model/card.rs
+++ /dev/null
@@ -1,9 +0,0 @@
-use crate::space_repetition;
-
-#[derive(Debug)]
-pub struct Card {
- pub question: String,
- pub responses: Vec<String>,
- pub state: space_repetition::State,
- pub ready: u64,
-}
diff --git a/src/model/entry.rs b/src/model/entry.rs
deleted file mode 100644
index 769b38c..0000000
--- a/src/model/entry.rs
+++ /dev/null
@@ -1,5 +0,0 @@
-#[derive(Debug, Clone)]
-pub struct Entry {
- pub part_1: Vec<String>,
- pub part_2: Vec<String>,
-}
diff --git a/src/model/mod.rs b/src/model/mod.rs
index 185f401..2dc1ab5 100644
--- a/src/model/mod.rs
+++ b/src/model/mod.rs
@@ -1,3 +1,29 @@
-pub mod card;
+use crate::space_repetition;
+
pub mod difficulty;
-pub mod entry;
+
+#[derive(Debug, Clone)]
+pub struct Line {
+ pub part_1: Vec<String>,
+ pub part_2: Vec<String>,
+}
+
+pub struct DbEntry {
+ pub question: String,
+ pub responses: Vec<String>,
+ pub deleted: Option<u64>,
+}
+
+#[derive(Debug)]
+pub struct Card {
+ pub question: String,
+ pub responses: Vec<String>,
+ pub state: space_repetition::State,
+ pub ready: u64,
+}
+
+#[derive(Debug, Clone, PartialEq, Eq, Hash)]
+pub struct Question {
+ pub question: String,
+ pub responses: Vec<String>,
+}