feat: add date_taken field to media model and update related functionalities

This commit is contained in:
2025-11-04 05:28:27 +01:00
parent 39ee8d52a4
commit 828d8e4a2b
11 changed files with 48 additions and 10 deletions

View File

@@ -47,6 +47,7 @@ pub struct PostgresMedia {
pub extracted_location: Option<String>,
pub width: Option<i32>,
pub height: Option<i32>,
pub date_taken: Option<chrono::DateTime<chrono::Utc>>,
}
#[derive(Debug, Clone, Copy, sqlx::Type, PartialEq, Eq, Deserialize)]

View File

@@ -63,6 +63,7 @@ impl From<PostgresMedia> for Media {
extracted_location: pg_media.extracted_location,
width: pg_media.width,
height: pg_media.height,
date_taken: pg_media.date_taken,
}
}
}

View File

@@ -50,7 +50,7 @@ impl MediaRepository for PostgresMediaRepository {
PostgresMedia,
r#"
SELECT id, owner_id, storage_path, original_filename, mime_type, hash, created_at,
extracted_location, width, height
extracted_location, width, height, date_taken
FROM media
WHERE hash = $1
"#,
@@ -68,7 +68,7 @@ impl MediaRepository for PostgresMediaRepository {
PostgresMedia,
r#"
SELECT id, owner_id, storage_path, original_filename, mime_type, hash, created_at,
extracted_location, width, height
extracted_location, width, height, date_taken
FROM media
WHERE id = $1
"#,
@@ -86,7 +86,7 @@ impl MediaRepository for PostgresMediaRepository {
PostgresMedia,
r#"
SELECT id, owner_id, storage_path, original_filename, mime_type, hash, created_at,
extracted_location, width, height
extracted_location, width, height, date_taken
FROM media
WHERE owner_id = $1
"#,
@@ -105,17 +105,19 @@ impl MediaRepository for PostgresMediaRepository {
width: Option<i32>,
height: Option<i32>,
location: Option<String>,
date_taken: Option<chrono::DateTime<chrono::Utc>>,
) -> CoreResult<()> {
sqlx::query!(
r#"
UPDATE media
SET width = $2, height = $3, extracted_location = $4
SET width = $2, height = $3, extracted_location = $4, date_taken = $5
WHERE id = $1
"#,
id,
width,
height,
location
location,
date_taken
)
.execute(&self.pool)
.await