Use is_valid for Id
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use crate::lang::{DeckSettings, OrderMode, INVALID_ID};
|
||||
use crate::lang::{DeckSettings, INVALID_ID, OrderMode};
|
||||
|
||||
use rusqlite::Connection;
|
||||
|
||||
@@ -47,7 +47,7 @@ pub fn add_set(set: &mut DeckSettings, connection: &Connection) {
|
||||
}
|
||||
|
||||
pub fn update_deck(set: &mut DeckSettings, connection: &Connection) {
|
||||
if set.id == INVALID_ID {
|
||||
if !set.id.is_valid() {
|
||||
add_set(set, connection);
|
||||
} else {
|
||||
connection
|
||||
@@ -66,7 +66,7 @@ pub fn update_deck(set: &mut DeckSettings, connection: &Connection) {
|
||||
}
|
||||
|
||||
pub fn delete_set(set: &DeckSettings, connection: &Connection) {
|
||||
if set.id == INVALID_ID {
|
||||
if !set.id.is_valid() {
|
||||
return;
|
||||
}
|
||||
connection
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::lang::{DeckSettings, CardStatistics, INVALID_ID};
|
||||
use crate::lang::{CardStatistics, DeckSettings, INVALID_ID};
|
||||
use rusqlite::Connection;
|
||||
use std::time::Instant;
|
||||
|
||||
@@ -64,7 +64,7 @@ pub fn add_stat_list(stat: &mut [CardStatistics], connection: &Connection) {
|
||||
for (index, id) in (start_index..=last_index).enumerate() {
|
||||
stat[index].id = id.into();
|
||||
}
|
||||
|
||||
|
||||
println!("Added {} cards for {:?}", stat.len(), time.elapsed());
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ pub fn update_stat_score(stat: &CardStatistics, connection: &Connection) {
|
||||
}
|
||||
|
||||
pub fn delete_stat(stat: &CardStatistics, connection: &Connection) {
|
||||
if stat.id == INVALID_ID {
|
||||
if !stat.id.is_valid() {
|
||||
return;
|
||||
}
|
||||
connection
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use hashbrown::HashMap;
|
||||
use rusqlite::Connection;
|
||||
use serde_json::Value;
|
||||
use hashbrown::HashMap;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct ImportData(pub(crate) Vec<ImportGroup>);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::lang::{WordData, WordGroup, INVALID_ID};
|
||||
use crate::lang::{INVALID_ID, WordData, WordGroup};
|
||||
use rusqlite::{Connection, params};
|
||||
use std::collections::HashMap;
|
||||
|
||||
@@ -64,7 +64,7 @@ pub fn add_words(words: &mut [WordData], connection: &mut Connection) {
|
||||
}
|
||||
|
||||
pub fn update_word(word: &mut WordData, connection: &Connection) {
|
||||
if word.id == INVALID_ID {
|
||||
if !word.id.is_valid() {
|
||||
add_word(word, connection);
|
||||
} else {
|
||||
connection
|
||||
@@ -86,7 +86,7 @@ pub fn update_word(word: &mut WordData, connection: &Connection) {
|
||||
}
|
||||
|
||||
pub fn delete_word(word: &WordData, connection: &Connection) {
|
||||
if word.id == INVALID_ID {
|
||||
if !word.id.is_valid() {
|
||||
return;
|
||||
}
|
||||
connection
|
||||
@@ -160,7 +160,7 @@ pub fn add_group(group: &mut WordGroup, connection: &Connection) {
|
||||
}
|
||||
|
||||
pub fn update_group(group: &mut WordGroup, connection: &Connection) {
|
||||
if group.id == INVALID_ID {
|
||||
if !group.id.is_valid() {
|
||||
add_group(group, connection);
|
||||
} else {
|
||||
connection
|
||||
@@ -176,7 +176,7 @@ pub fn update_group(group: &mut WordGroup, connection: &Connection) {
|
||||
}
|
||||
|
||||
pub fn delete_group(group: &WordGroup, connection: &Connection) {
|
||||
if group.id == INVALID_ID {
|
||||
if !group.id.is_valid() {
|
||||
return;
|
||||
}
|
||||
connection
|
||||
|
||||
Reference in New Issue
Block a user