Db saving cases
This commit is contained in:
1 parent
294f0e8b98
commit
3663765284
4 files changed
+23
-3
No files matched your search
@@ -190,7 +190,7 @@ impl<T: EntityData + Clone + Send + Sync, R: Repository<T, D>, D: DbLayer<T>> Qu
|
|||||||
.collect::<Vec<_>>(),
|
.collect::<Vec<_>>(),
|
||||||
);
|
);
|
||||||
|
|
||||||
debug!("Query for {} elements (filtered {}) takes {:?}", self.len(), self.cache.len(), time.elapsed());
|
debug!("Query for {} elements (filtered {}) takes {:?}", data_repository.len(), self.cache.len(), time.elapsed());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handles(&self) -> impl Iterator<Item = EntityHandle<T>> {
|
pub fn handles(&self) -> impl Iterator<Item = EntityHandle<T>> {
|
||||||
|
|||||||
@@ -116,9 +116,10 @@ impl SqliteConnection {
|
|||||||
error!("Ошибка при checkpoint WAL: {e}");
|
error!("Ошибка при checkpoint WAL: {e}");
|
||||||
});
|
});
|
||||||
connection
|
connection
|
||||||
.query_row("PRAGMA optimize", [], |_| Ok(()))
|
.execute("PRAGMA optimize", [])
|
||||||
.unwrap_or_else(|e| {
|
.unwrap_or_else(|e| {
|
||||||
error!("Ошибка при оптимизации БД: {e}");
|
error!("Ошибка при оптимизации БД: {e}");
|
||||||
|
0
|
||||||
});
|
});
|
||||||
|
|
||||||
self.0 = None;
|
self.0 = None;
|
||||||
@@ -127,3 +128,8 @@ impl SqliteConnection {
|
|||||||
self.0 = Some(default_connection());
|
self.0 = Some(default_connection());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Drop for SqliteConnection {
|
||||||
|
|
||||||
|
fn drop(&mut self) { self.finish(); }
|
||||||
|
}
|
||||||
@@ -106,6 +106,9 @@ impl NavigatedPage<DictionaryMessage> for DictionaryState {
|
|||||||
fn navigated(&mut self) {
|
fn navigated(&mut self) {
|
||||||
self.included = Default::default();
|
self.included = Default::default();
|
||||||
self.tag_map = Default::default();
|
self.tag_map = Default::default();
|
||||||
|
let groups = self.state.word_groups.read();
|
||||||
|
self.groups_query.load(&groups);
|
||||||
|
drop(groups);
|
||||||
self.update_tags();
|
self.update_tags();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+12
-1
@@ -273,7 +273,18 @@ impl SyncState {
|
|||||||
.unwrap_or_else(|e| {
|
.unwrap_or_else(|e| {
|
||||||
error!("Ошибка при checkpoint WAL: {e}");
|
error!("Ошибка при checkpoint WAL: {e}");
|
||||||
});
|
});
|
||||||
|
connection
|
||||||
|
.execute("VACUUM;", [])
|
||||||
|
.unwrap_or_else(|e| {
|
||||||
|
error!("Ошибка при checkpoint WAL: {e}");
|
||||||
|
0
|
||||||
|
});
|
||||||
|
connection
|
||||||
|
.execute("PRAGMA optimize;", [])
|
||||||
|
.unwrap_or_else(|e| {
|
||||||
|
error!("Ошибка при checkpoint WAL: {e}");
|
||||||
|
0
|
||||||
|
});
|
||||||
connection.finish();
|
connection.finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user