Add added_date field to Song and SongData
Some checks failed
Push Workflows / docs (push) Successful in 2m8s
Push Workflows / build (push) Failing after 2m53s
Push Workflows / test (push) Successful in 5m7s
Push Workflows / leptos-test (push) Successful in 6m16s
Push Workflows / docker-build (push) Failing after 14m38s

This commit is contained in:
2024-12-15 17:20:18 -05:00
parent 9f39c9b3fd
commit b7b6406c2d
5 changed files with 12 additions and 0 deletions

View File

@ -141,6 +141,7 @@ pub async fn recent_songs(for_user_id: i32, limit: Option<i64>) -> Result<Vec<(N
song_path: song.storage_path,
image_path: image_path,
like_dislike: like_dislike,
added_date: song.added_date.unwrap(),
};
history_songs.insert(song_id, (history.date, songdata));
@ -239,6 +240,7 @@ pub async fn top_songs(for_user_id: i32, start_date: NaiveDateTime, end_date: Na
song_path: song.storage_path,
image_path: image_path,
like_dislike: like_dislike,
added_date: song.added_date.unwrap(),
};
let plays = history_counts.get(&song_id)

View File

@ -652,6 +652,7 @@ impl Album {
song_path: song.storage_path,
image_path: image_path,
like_dislike: like_dislike,
added_date: song.added_date.unwrap(),
};
album_songs.insert(song.id.unwrap(), songdata);
@ -689,6 +690,9 @@ pub struct Song {
pub storage_path: String,
/// The path to the song's image file
pub image_path: Option<String>,
/// The date the song was added to the database
#[cfg_attr(feature = "ssr", diesel(deserialize_as = NaiveDate))]
pub added_date: Option<NaiveDate>,
}
impl Song {

View File

@ -96,6 +96,7 @@ diesel::table! {
release_date -> Nullable<Date>,
storage_path -> Varchar,
image_path -> Nullable<Varchar>,
added_date -> Date,
}
}

View File

@ -31,6 +31,8 @@ pub struct SongData {
pub image_path: String,
/// Whether the song is liked by the user
pub like_dislike: Option<(bool, bool)>,
/// The date the song was added to the database
pub added_date: NaiveDate,
}
@ -59,6 +61,8 @@ impl TryInto<Song> for SongData {
} else {
Some(self.image_path)
},
added_date: Some(self.added_date),
})
}
}

View File

@ -253,6 +253,7 @@ pub async fn upload(data: MultipartData) -> Result<(), ServerFnError> {
release_date,
storage_path: file_name,
image_path: None,
added_date: None, // Defaults to current date
};
// Save the song to the database