update todo
This commit is contained in:
parent
362a31581d
commit
ba51c56169
2 changed files with 20 additions and 8 deletions
3
TODO.org
3
TODO.org
|
@ -44,6 +44,9 @@ I've got SlideType enums working
|
||||||
*** Move logic of changing slides to slide_model
|
*** Move logic of changing slides to slide_model
|
||||||
Since the slide_object is merely supposed to be the view of the current slide, deciding which slide to switch to should be entirely on the slide_model, not the slide_object. This way slide_object doesn't need to know anything about the which slide is next and instead have a function to update everything to the slide returned from slide_model's new slide.
|
Since the slide_object is merely supposed to be the view of the current slide, deciding which slide to switch to should be entirely on the slide_model, not the slide_object. This way slide_object doesn't need to know anything about the which slide is next and instead have a function to update everything to the slide returned from slide_model's new slide.
|
||||||
|
|
||||||
|
*** Move all big logic to library crate for using rust data types better
|
||||||
|
I've started to move all the real logic to a pure rust library that can be consumed and used by the cxx-qt rust parts in QML. This could also pave the way to using any other rust gui instead of QML in the future.
|
||||||
|
|
||||||
** TODO [#A] Consider converting diesel to raw sqlx instead
|
** TODO [#A] Consider converting diesel to raw sqlx instead
|
||||||
From what I can gather, sometimes an orm is just too hard to work around rather than doing raw sql queries. The only issue is that my queries have been rather small. I only really need to select everything into the app and then run it from there. However, it could still be a consideration as things age. Perhaps when there are hundreds or even thousands of items in the database, it'll be more effective to use something like SQLx.
|
From what I can gather, sometimes an orm is just too hard to work around rather than doing raw sql queries. The only issue is that my queries have been rather small. I only really need to select everything into the app and then run it from there. However, it could still be a consideration as things age. Perhaps when there are hundreds or even thousands of items in the database, it'll be more effective to use something like SQLx.
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
use std::path::PathBuf;
|
|
||||||
use sqlx::query_as;
|
|
||||||
use tracing::error;
|
|
||||||
use crate::model::Model;
|
use crate::model::Model;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use sqlx::query_as;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
use tracing::error;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, PartialEq)]
|
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
|
||||||
pub struct Image {
|
pub struct Image {
|
||||||
|
pub id: i32,
|
||||||
pub title: String,
|
pub title: String,
|
||||||
pub path: PathBuf,
|
pub path: PathBuf,
|
||||||
}
|
}
|
||||||
|
@ -13,14 +15,14 @@ impl Model<Image> {
|
||||||
pub fn load_from_db(&mut self) {
|
pub fn load_from_db(&mut self) {
|
||||||
let rt = tokio::runtime::Runtime::new().unwrap();
|
let rt = tokio::runtime::Runtime::new().unwrap();
|
||||||
rt.block_on(async {
|
rt.block_on(async {
|
||||||
let result = query_as!(Image, r#"SELECT title as "title!", filePath as "path!" from images"#).fetch_all(&mut self.db).await;
|
let result = query_as!(Image, r#"SELECT title as "title!", filePath as "path!", id as "id: i32" from images"#).fetch_all(&mut self.db).await;
|
||||||
match result {
|
match result {
|
||||||
Ok(v) => {
|
Ok(v) => {
|
||||||
for image in v.into_iter() {
|
for image in v.into_iter() {
|
||||||
let _ = self.add_item(image);
|
let _ = self.add_item(image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(e) => error!("There was an error in converting songs: {e}"),
|
Err(e) => error!("There was an error in converting images: {e}"),
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -60,9 +62,16 @@ mod test {
|
||||||
match result {
|
match result {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
assert_eq!(&image, image_model.get_item(0).unwrap());
|
assert_eq!(&image, image_model.get_item(0).unwrap());
|
||||||
assert_ne!(&new_image, image_model.get_item(0).unwrap());
|
assert_ne!(
|
||||||
|
&new_image,
|
||||||
|
image_model.get_item(0).unwrap()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
Err(e) => assert!(false, "There was an error adding the image: {:?}", e),
|
Err(e) => assert!(
|
||||||
|
false,
|
||||||
|
"There was an error adding the image: {:?}",
|
||||||
|
e
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue