From 9a9e77a3bbdd415c77e63224d52d562313f80176 Mon Sep 17 00:00:00 2001 From: JMARyA Date: Fri, 9 Aug 2024 22:04:27 +0200 Subject: [PATCH] update --- Cargo.lock | 1 + Cargo.toml | 1 + src/cache.rs | 12 ++++++------ src/library/track.rs | 2 ++ 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 87fddde..7b8715e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2010,6 +2010,7 @@ name = "synthwave" version = "0.1.0" dependencies = [ "bcrypt", + "chrono", "data-encoding", "env_logger", "log", diff --git a/Cargo.toml b/Cargo.toml index 8093f5d..acfa8d6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,3 +17,4 @@ data-encoding = "2.6.0" rand = "0.8.5" env_logger = "0.11.5" log = "0.4.22" +chrono = "0.4.38" diff --git a/src/cache.rs b/src/cache.rs index b4ff271..8ae67f0 100644 --- a/src/cache.rs +++ b/src/cache.rs @@ -32,7 +32,7 @@ impl RouteCache { let lock = self.inner.read().await; if let Some(inner_map) = lock.get(route) { if let Some(cached_value) = inner_map.get(id) { - log::trace!("Using cached value for {route} / {id}"); + log::info!("Using cached value for {route} / {id}"); return cached_value.clone().unwrap(); } } @@ -41,7 +41,7 @@ impl RouteCache { // If the value was not found, acquire a write lock to insert the computed value. let mut lock = self.inner.write().await; - log::trace!("Computing value for {route} / {id}"); + log::info!("Computing value for {route} / {id}"); let computed = generator().await; lock.entry(route.to_string()) @@ -55,7 +55,7 @@ impl RouteCache { let lock = self.inner.read().await; if let Some(inner_map) = lock.get(route) { if let Some(cached_value) = inner_map.get(id) { - log::trace!("Using cached value for {route} / {id}"); + log::info!("Using cached value for {route} / {id}"); return cached_value.clone(); } } @@ -73,7 +73,7 @@ impl RouteCache { let lock = self.inner.read().await; if let Some(inner_map) = lock.get(route) { if let Some(cached_value) = inner_map.get(id) { - log::trace!("Using cached value for {route} / {id}"); + log::info!("Using cached value for {route} / {id}"); return cached_value.clone(); } } @@ -82,7 +82,7 @@ impl RouteCache { // If the value was not found, acquire a write lock to insert the computed value. let mut lock = self.inner.write().await; - log::trace!("Computing value for {route} / {id}"); + log::info!("Computing value for {route} / {id}"); let computed = generator().await; lock.entry(route.to_string()) @@ -95,7 +95,7 @@ impl RouteCache { pub async fn insert(&self, route: &str, id: &str, value: String) { let mut lock = self.inner.write().await; - log::trace!("Inserting value for {route} / {id}"); + log::info!("Inserting value for {route} / {id}"); lock.entry(route.to_string()) .or_insert_with(HashMap::new) diff --git a/src/library/track.rs b/src/library/track.rs index ee29faa..156bc0e 100644 --- a/src/library/track.rs +++ b/src/library/track.rs @@ -19,6 +19,7 @@ pub struct Track { pub _id: String, pub path: String, pub title: String, + pub date_added: i64, pub album_id: Option, pub artist_id: Option, pub meta: Option, @@ -30,6 +31,7 @@ impl Track { _id: uuid::Uuid::new_v4().to_string(), path: data.get("path").unwrap().as_str().unwrap().to_string(), title: data.get("title").unwrap().as_str().unwrap().to_string(), + date_added: chrono::Utc::now().timestamp(), album_id: None, artist_id: None, meta: data.get("meta").map(|x| AudioMetadata(x.clone())),