feat: Add media details sidebar and date handling features, including media grouping by date

This commit is contained in:
2025-11-16 03:32:18 +01:00
parent 94b184d3b0
commit 2003a55ff7
16 changed files with 362 additions and 52 deletions

View File

@@ -0,0 +1,4 @@
ALTER TABLE media
ADD COLUMN date_taken TIMESTAMPTZ;
CREATE INDEX IF NOT EXISTS idx_media_date_taken ON media (date_taken);

View File

@@ -14,6 +14,8 @@ pub struct MediaResponse {
pub hash: String,
pub file_url: String,
pub thumbnail_url: Option<String>,
pub created_at: chrono::DateTime<chrono::Utc>,
pub date_taken: Option<chrono::DateTime<chrono::Utc>>,
}
impl From<Media> for MediaResponse {
@@ -27,6 +29,8 @@ impl From<Media> for MediaResponse {
thumbnail_url: media
.thumbnail_path
.map(|_| format!("/api/v1/media/{}/thumbnail", media.id)),
created_at: media.created_at,
date_taken: media.date_taken,
}
}
}

View File

@@ -67,7 +67,7 @@ impl MediaService for MediaServiceImpl {
.await
.unwrap()?;
let (storage_path_buf, _date_taken) = get_storage_path_and_date(&extracted_data, &filename);
let (storage_path_buf, date_taken) = get_storage_path_and_date(&extracted_data, &filename);
let storage_path_str = self
.persist_media_file(&file_bytes, &storage_path_buf)
@@ -81,6 +81,7 @@ impl MediaService for MediaServiceImpl {
storage_path_str,
hash,
file_size,
date_taken,
)
.await?;
@@ -282,6 +283,7 @@ impl MediaServiceImpl {
storage_path: String,
hash: String,
file_size: i64,
date_taken: Option<chrono::DateTime<chrono::Utc>>,
) -> CoreResult<Media> {
let media_model = Media {
id: Uuid::new_v4(),
@@ -292,6 +294,7 @@ impl MediaServiceImpl {
hash,
created_at: chrono::Utc::now(),
thumbnail_path: None,
date_taken,
};
self.repo.create(&media_model).await?;