From b0ef079678a50ec6868d56e8c18753519f193d4a Mon Sep 17 00:00:00 2001 From: Rasmus Kaj Date: Wed, 31 Jul 2024 22:22:59 +0200 Subject: [PATCH] Remove unneded db model structs. --- CHANGELOG.md | 1 + src/fetch_places.rs | 4 ++-- src/models.rs | 19 ------------------- src/server/admin.rs | 5 +++-- 4 files changed, 6 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd8502c..96de534 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ The format is based on * Improved item (image) sizing css. I hope it works in safari. * Updated to `diesel` 2.1.0, `diesel-async` 0.3.2, and `ructe` 0.17.0. * Uses std LazyLock (require rust 1.80) instead of `lazy_regex`. +* Removed unneded db model structs. * Some more known kinds of places. diff --git a/src/fetch_places.rs b/src/fetch_places.rs index 8b66777..7be5c06 100644 --- a/src/fetch_places.rs +++ b/src/fetch_places.rs @@ -1,4 +1,3 @@ -use crate::models::PhotoPlace; use crate::models::{Coord, Place}; use crate::schema::photo_places::dsl as pl; use crate::schema::places::dsl as l; @@ -107,9 +106,10 @@ impl OverpassOpt { .await .map_err(|e| Error::Db(image, e))?; let q = pl::photo_places + .select(pl::place_id) .filter(pl::photo_id.eq(image)) .filter(pl::place_id.eq(place.id)); - if q.first::(db).await.is_ok() { + if q.first::(db).await.is_ok() { debug!( "Photo #{} already has {} ({})", image, place.id, place.place_name diff --git a/src/models.rs b/src/models.rs index 05a6fe2..14f75b2 100644 --- a/src/models.rs +++ b/src/models.rs @@ -282,13 +282,6 @@ impl Facet for Tag { } } -#[derive(Debug, Clone, Queryable)] -pub struct PhotoTag { - pub id: i32, - pub photo_id: i32, - pub tag_id: i32, -} - #[derive(Debug, Clone, Queryable)] pub struct Person { pub id: i32, @@ -327,12 +320,6 @@ impl Facet for Person { } } -#[derive(Debug, Clone, Queryable)] -pub struct PhotoPerson { - pub photo_id: i32, - pub person_id: i32, -} - #[derive(Debug, Clone, Queryable)] pub struct Place { pub id: i32, @@ -352,12 +339,6 @@ impl Facet for Place { } } -#[derive(Debug, Clone, Queryable)] -pub struct PhotoPlace { - pub photo_id: i32, - pub place_id: i32, -} - #[derive(Debug, Clone, Identifiable, Queryable)] pub struct Camera { pub id: i32, diff --git a/src/server/admin.rs b/src/server/admin.rs index 8b546f5..4dc160e 100644 --- a/src/server/admin.rs +++ b/src/server/admin.rs @@ -1,7 +1,7 @@ //! Admin-only views, generally called by javascript. use super::error::ViewResult; use super::{redirect_to_img, wrap, Context, Result, ViewError}; -use crate::models::{Coord, Person, Photo, PhotoPerson, SizeTag, Tag}; +use crate::models::{Coord, Person, Photo, SizeTag, Tag}; use crate::schema::photo_people::dsl as pp; use crate::schema::photo_tags::dsl as pt; use crate::schema::photos::dsl as p; @@ -111,9 +111,10 @@ async fn set_person(context: Context, form: PersonForm) -> Result { let mut c = context.db().await?; let person = Person::get_or_create_name(&mut c, &form.person).await?; let q = pp::photo_people + .select(pp::person_id) .filter(pp::photo_id.eq(form.image)) .filter(pp::person_id.eq(person.id)); - if q.first::(&mut c).await.optional()?.is_some() { + if q.first::(&mut c).await.optional()?.is_some() { info!("Photo #{} already has {:?}", form.image, person); } else { info!("Add {:?} on photo #{}!", person, form.image);