Add added_date field to Song and SongData
Some checks failed
Some checks failed
This commit is contained in:
@ -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)
|
||||
|
@ -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 {
|
||||
|
@ -96,6 +96,7 @@ diesel::table! {
|
||||
release_date -> Nullable<Date>,
|
||||
storage_path -> Varchar,
|
||||
image_path -> Nullable<Varchar>,
|
||||
added_date -> Date,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user