This commit is contained in:
JMARyA 2024-08-09 22:04:27 +02:00
parent 95c5592170
commit 9a9e77a3bb
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
4 changed files with 10 additions and 6 deletions

1
Cargo.lock generated
View file

@ -2010,6 +2010,7 @@ name = "synthwave"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"bcrypt", "bcrypt",
"chrono",
"data-encoding", "data-encoding",
"env_logger", "env_logger",
"log", "log",

View file

@ -17,3 +17,4 @@ data-encoding = "2.6.0"
rand = "0.8.5" rand = "0.8.5"
env_logger = "0.11.5" env_logger = "0.11.5"
log = "0.4.22" log = "0.4.22"
chrono = "0.4.38"

View file

@ -32,7 +32,7 @@ impl RouteCache {
let lock = self.inner.read().await; let lock = self.inner.read().await;
if let Some(inner_map) = lock.get(route) { if let Some(inner_map) = lock.get(route) {
if let Some(cached_value) = inner_map.get(id) { 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(); 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. // If the value was not found, acquire a write lock to insert the computed value.
let mut lock = self.inner.write().await; 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; let computed = generator().await;
lock.entry(route.to_string()) lock.entry(route.to_string())
@ -55,7 +55,7 @@ impl RouteCache {
let lock = self.inner.read().await; let lock = self.inner.read().await;
if let Some(inner_map) = lock.get(route) { if let Some(inner_map) = lock.get(route) {
if let Some(cached_value) = inner_map.get(id) { 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(); return cached_value.clone();
} }
} }
@ -73,7 +73,7 @@ impl RouteCache {
let lock = self.inner.read().await; let lock = self.inner.read().await;
if let Some(inner_map) = lock.get(route) { if let Some(inner_map) = lock.get(route) {
if let Some(cached_value) = inner_map.get(id) { 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(); 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. // If the value was not found, acquire a write lock to insert the computed value.
let mut lock = self.inner.write().await; 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; let computed = generator().await;
lock.entry(route.to_string()) lock.entry(route.to_string())
@ -95,7 +95,7 @@ impl RouteCache {
pub async fn insert(&self, route: &str, id: &str, value: String) { pub async fn insert(&self, route: &str, id: &str, value: String) {
let mut lock = self.inner.write().await; 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()) lock.entry(route.to_string())
.or_insert_with(HashMap::new) .or_insert_with(HashMap::new)

View file

@ -19,6 +19,7 @@ pub struct Track {
pub _id: String, pub _id: String,
pub path: String, pub path: String,
pub title: String, pub title: String,
pub date_added: i64,
pub album_id: Option<Reference>, pub album_id: Option<Reference>,
pub artist_id: Option<Reference>, pub artist_id: Option<Reference>,
pub meta: Option<AudioMetadata>, pub meta: Option<AudioMetadata>,
@ -30,6 +31,7 @@ impl Track {
_id: uuid::Uuid::new_v4().to_string(), _id: uuid::Uuid::new_v4().to_string(),
path: data.get("path").unwrap().as_str().unwrap().to_string(), path: data.get("path").unwrap().as_str().unwrap().to_string(),
title: data.get("title").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, album_id: None,
artist_id: None, artist_id: None,
meta: data.get("meta").map(|x| AudioMetadata(x.clone())), meta: data.get("meta").map(|x| AudioMetadata(x.clone())),