Added tests for radarr models and refactored get_movie_status to live inside the radarr_network module

This commit is contained in:
2023-08-08 10:50:05 -06:00
parent 4962f3d5c3
commit f38de0a6c3
3 changed files with 67 additions and 25 deletions
-21
View File
@@ -7,24 +7,3 @@ use crate::models::radarr_models::DownloadRecord;
pub async fn parse_response<T: DeserializeOwned>(response: Response) -> Result<T, reqwest::Error> {
response.json::<T>().await
}
pub fn get_movie_status(
has_file: bool,
downloads_vec: &[DownloadRecord],
movie_id: Number,
) -> String {
if !has_file {
if let Some(download) = downloads_vec
.iter()
.find(|&download| download.id.as_u64().unwrap() == movie_id.as_u64().unwrap())
{
if download.status == "downloading" {
return "Downloading".to_owned();
}
}
return "Missing".to_owned();
}
"Downloaded".to_owned()
}