diff --git a/Cargo.lock b/Cargo.lock index 85ae352..4e42bd5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -351,7 +351,6 @@ dependencies = [ "diesel_migrations", "futures", "image", - "libsqlite3-sys", "mime", "rand", "serde", @@ -1089,7 +1088,6 @@ version = "0.30.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e99fb7a497b1e3339bc746195567ed8d3e24945ecd636e3619d20b9de9e9149" dependencies = [ - "cc", "pkg-config", "vcpkg", ] diff --git a/Cargo.toml b/Cargo.toml index eb5d537..d26e04f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,12 +15,12 @@ chrono = { version = "0.4.39", features = ["serde"] } clap = { version = "4.5.26", features = ["derive", "env"] } diesel = { version = "2.2.6", features = ["sqlite", "returning_clauses_for_sqlite_3_35", "r2d2", "chrono"] } diesel_migrations = { version = "2.2.0", features = ["sqlite"] } -# Forces diesel to include a bundled version of Sqlite -libsqlite3-sys = {version = ">=0.17.2, <0.31.0", features = ["bundled"]} futures = "0.3.31" image = { version = "0.25.5", default-features = false, features = ["gif", "jpeg", "png"] } mime = "0.3.17" rand = "0.8.5" +# this dependency is needed soly because the r2d2_sqlite crate doesn't export +# the 'chrono' feature flag serde = { version = "1.0.217", features = ["derive"] } tera = "1.20.0" tokio = { version = "1.42.0", features = ["full"] } diff --git a/src/db/models/image.rs b/src/db/models/image.rs index 539537f..159f1a0 100644 --- a/src/db/models/image.rs +++ b/src/db/models/image.rs @@ -2,7 +2,7 @@ use chrono::NaiveDate; use diesel::prelude::*; use serde::{Deserialize, Serialize}; -use crate::db::{schema::*, DbPool, DbResult, Pagination, Plant}; +use crate::db::{schema::*, DbPool, DbResult, Pagination}; #[derive(Serialize, Queryable, Selectable)] #[diesel(table_name = images)] @@ -62,15 +62,8 @@ impl Image { .optional()?) } - pub fn page_with_plants( - pool: &DbPool, - page: Pagination, - filter: ImageFilter, - ) -> DbResult> { - let mut query = images::table - .inner_join(plants::table) - .select((Self::as_select(), Plant::as_select())) - .into_boxed(); + pub fn page(pool: &DbPool, page: Pagination, filter: ImageFilter) -> DbResult> { + let mut query = images::table.select(Self::as_select()).into_boxed(); if let Some(plant_id) = filter.plant_id { query = query.filter(images::dsl::plant_id.eq(plant_id)); diff --git a/src/server/images.rs b/src/server/images.rs index 15e8894..957f587 100644 --- a/src/server/images.rs +++ b/src/server/images.rs @@ -66,10 +66,9 @@ async fn get_images( Query(filter): Query, headers: HeaderMap, ) -> super::Result> { - let images = - tokio::task::spawn_blocking(move || db::Image::page_with_plants(&ctx.pool, page, filter)) - .await - .unwrap()?; + let images = tokio::task::spawn_blocking(move || db::Image::page(&ctx.pool, page, filter)) + .await + .unwrap()?; let mut context = Context::new(); context.insert("images", &images); diff --git a/templates/components/plant.html b/templates/components/plant.html index a654bb5..32432b0 100644 --- a/templates/components/plant.html +++ b/templates/components/plant.html @@ -35,7 +35,3 @@ {% endmacro %} - -{% macro name(plant) %} -{{ plant.name }} ({{ plant.species }}) -{% endmacro %} diff --git a/templates/views/images.html b/templates/views/images.html index d70cca0..972c23a 100644 --- a/templates/views/images.html +++ b/templates/views/images.html @@ -1,13 +1,10 @@ -{% import "components/plant.html" as comp_plant %} -

Images

{% for image in images %} {% endfor %}