fix(blocklist_handler): Fixed a breaking change between Sonarr v3 and v4
This commit is contained in:
@@ -441,10 +441,20 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_blocklist_sorting_options_language() {
|
fn test_blocklist_sorting_options_language() {
|
||||||
let expected_cmp_fn: fn(&BlocklistItem, &BlocklistItem) -> Ordering = |a, b| {
|
let expected_cmp_fn: fn(&BlocklistItem, &BlocklistItem) -> Ordering = |a, b| {
|
||||||
a.language
|
let a_languages = a
|
||||||
.name
|
.languages
|
||||||
.to_lowercase()
|
.iter()
|
||||||
.cmp(&b.language.name.to_lowercase())
|
.map(|lang| lang.name.to_lowercase())
|
||||||
|
.collect::<Vec<String>>()
|
||||||
|
.join(", ");
|
||||||
|
let b_languages = b
|
||||||
|
.languages
|
||||||
|
.iter()
|
||||||
|
.map(|lang| lang.name.to_lowercase())
|
||||||
|
.collect::<Vec<String>>()
|
||||||
|
.join(", ");
|
||||||
|
|
||||||
|
a_languages.cmp(&b_languages)
|
||||||
};
|
};
|
||||||
let mut expected_blocklist_vec = blocklist_vec();
|
let mut expected_blocklist_vec = blocklist_vec();
|
||||||
expected_blocklist_vec.sort_by(expected_cmp_fn);
|
expected_blocklist_vec.sort_by(expected_cmp_fn);
|
||||||
@@ -561,10 +571,10 @@ mod tests {
|
|||||||
BlocklistItem {
|
BlocklistItem {
|
||||||
id: 3,
|
id: 3,
|
||||||
source_title: "test 1".to_owned(),
|
source_title: "test 1".to_owned(),
|
||||||
language: Language {
|
languages: vec![Language {
|
||||||
id: 1,
|
id: 1,
|
||||||
name: "telgu".to_owned(),
|
name: "telgu".to_owned(),
|
||||||
},
|
}],
|
||||||
quality: QualityWrapper {
|
quality: QualityWrapper {
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
name: "HD - 1080p".to_owned(),
|
name: "HD - 1080p".to_owned(),
|
||||||
@@ -577,10 +587,10 @@ mod tests {
|
|||||||
BlocklistItem {
|
BlocklistItem {
|
||||||
id: 2,
|
id: 2,
|
||||||
source_title: "test 2".to_owned(),
|
source_title: "test 2".to_owned(),
|
||||||
language: Language {
|
languages: vec![Language {
|
||||||
id: 3,
|
id: 3,
|
||||||
name: "chinese".to_owned(),
|
name: "chinese".to_owned(),
|
||||||
},
|
}],
|
||||||
quality: QualityWrapper {
|
quality: QualityWrapper {
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
name: "SD - 720p".to_owned(),
|
name: "SD - 720p".to_owned(),
|
||||||
@@ -593,10 +603,10 @@ mod tests {
|
|||||||
BlocklistItem {
|
BlocklistItem {
|
||||||
id: 1,
|
id: 1,
|
||||||
source_title: "test 3".to_owned(),
|
source_title: "test 3".to_owned(),
|
||||||
language: Language {
|
languages: vec![Language {
|
||||||
id: 1,
|
id: 1,
|
||||||
name: "english".to_owned(),
|
name: "english".to_owned(),
|
||||||
},
|
}],
|
||||||
quality: QualityWrapper {
|
quality: QualityWrapper {
|
||||||
quality: Quality {
|
quality: Quality {
|
||||||
name: "HD - 1080p".to_owned(),
|
name: "HD - 1080p".to_owned(),
|
||||||
|
|||||||
@@ -198,10 +198,20 @@ fn blocklist_sorting_options() -> Vec<SortOption<BlocklistItem>> {
|
|||||||
SortOption {
|
SortOption {
|
||||||
name: "Language",
|
name: "Language",
|
||||||
cmp_fn: Some(|a, b| {
|
cmp_fn: Some(|a, b| {
|
||||||
a.language
|
let a_languages = a
|
||||||
.name
|
.languages
|
||||||
.to_lowercase()
|
.iter()
|
||||||
.cmp(&b.language.name.to_lowercase())
|
.map(|lang| lang.name.to_lowercase())
|
||||||
|
.collect::<Vec<String>>()
|
||||||
|
.join(", ");
|
||||||
|
let b_languages = b
|
||||||
|
.languages
|
||||||
|
.iter()
|
||||||
|
.map(|lang| lang.name.to_lowercase())
|
||||||
|
.collect::<Vec<String>>()
|
||||||
|
.join(", ");
|
||||||
|
|
||||||
|
a_languages.cmp(&b_languages)
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
SortOption {
|
SortOption {
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ pub struct BlocklistItem {
|
|||||||
pub series_title: Option<String>,
|
pub series_title: Option<String>,
|
||||||
pub episode_ids: Vec<Number>,
|
pub episode_ids: Vec<Number>,
|
||||||
pub source_title: String,
|
pub source_title: String,
|
||||||
pub language: Language,
|
pub languages: Vec<Language>,
|
||||||
pub quality: QualityWrapper,
|
pub quality: QualityWrapper,
|
||||||
pub date: DateTime<Utc>,
|
pub date: DateTime<Utc>,
|
||||||
pub protocol: String,
|
pub protocol: String,
|
||||||
|
|||||||
@@ -1958,7 +1958,7 @@ mod test {
|
|||||||
"seriesId": 1007,
|
"seriesId": 1007,
|
||||||
"episodeIds": [42020],
|
"episodeIds": [42020],
|
||||||
"sourceTitle": "z series",
|
"sourceTitle": "z series",
|
||||||
"language": { "id": 1, "name": "English" },
|
"languages": [{ "id": 1, "name": "English" }],
|
||||||
"quality": { "quality": { "name": "Bluray-1080p" }},
|
"quality": { "quality": { "name": "Bluray-1080p" }},
|
||||||
"date": "2024-02-10T07:28:45Z",
|
"date": "2024-02-10T07:28:45Z",
|
||||||
"protocol": "usenet",
|
"protocol": "usenet",
|
||||||
@@ -1970,7 +1970,7 @@ mod test {
|
|||||||
"seriesId": 2001,
|
"seriesId": 2001,
|
||||||
"episodeIds": [42018],
|
"episodeIds": [42018],
|
||||||
"sourceTitle": "A Series",
|
"sourceTitle": "A Series",
|
||||||
"language": { "id": 1, "name": "English" },
|
"languages": [{ "id": 1, "name": "English" }],
|
||||||
"quality": { "quality": { "name": "Bluray-1080p" }},
|
"quality": { "quality": { "name": "Bluray-1080p" }},
|
||||||
"date": "2024-02-10T07:28:45Z",
|
"date": "2024-02-10T07:28:45Z",
|
||||||
"protocol": "usenet",
|
"protocol": "usenet",
|
||||||
@@ -2061,7 +2061,7 @@ mod test {
|
|||||||
"seriesId": 1007,
|
"seriesId": 1007,
|
||||||
"episodeIds": [42020],
|
"episodeIds": [42020],
|
||||||
"sourceTitle": "z series",
|
"sourceTitle": "z series",
|
||||||
"language": { "id": 1, "name": "English" },
|
"languages": [{ "id": 1, "name": "English" }],
|
||||||
"quality": { "quality": { "name": "Bluray-1080p" }},
|
"quality": { "quality": { "name": "Bluray-1080p" }},
|
||||||
"date": "2024-02-10T07:28:45Z",
|
"date": "2024-02-10T07:28:45Z",
|
||||||
"protocol": "usenet",
|
"protocol": "usenet",
|
||||||
@@ -2073,7 +2073,7 @@ mod test {
|
|||||||
"seriesId": 2001,
|
"seriesId": 2001,
|
||||||
"episodeIds": [42018],
|
"episodeIds": [42018],
|
||||||
"sourceTitle": "A Series",
|
"sourceTitle": "A Series",
|
||||||
"language": { "id": 1, "name": "English" },
|
"languages": [{ "id": 1, "name": "English" }],
|
||||||
"quality": { "quality": { "name": "Bluray-1080p" }},
|
"quality": { "quality": { "name": "Bluray-1080p" }},
|
||||||
"date": "2024-02-10T07:28:45Z",
|
"date": "2024-02-10T07:28:45Z",
|
||||||
"protocol": "usenet",
|
"protocol": "usenet",
|
||||||
@@ -7541,7 +7541,7 @@ mod test {
|
|||||||
series_title: None,
|
series_title: None,
|
||||||
episode_ids: vec![Number::from(1)],
|
episode_ids: vec![Number::from(1)],
|
||||||
source_title: "Test Source Title".to_owned(),
|
source_title: "Test Source Title".to_owned(),
|
||||||
language: language(),
|
languages: vec![language()],
|
||||||
quality: quality_wrapper(),
|
quality: quality_wrapper(),
|
||||||
date: DateTime::from(DateTime::parse_from_rfc3339("2024-02-10T07:28:45Z").unwrap()),
|
date: DateTime::from(DateTime::parse_from_rfc3339("2024-02-10T07:28:45Z").unwrap()),
|
||||||
protocol: "usenet".to_owned(),
|
protocol: "usenet".to_owned(),
|
||||||
|
|||||||
@@ -87,18 +87,23 @@ fn draw_blocklist_table(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
|||||||
let BlocklistItem {
|
let BlocklistItem {
|
||||||
source_title,
|
source_title,
|
||||||
series_title,
|
series_title,
|
||||||
language,
|
languages,
|
||||||
quality,
|
quality,
|
||||||
date,
|
date,
|
||||||
..
|
..
|
||||||
} = blocklist_item;
|
} = blocklist_item;
|
||||||
|
|
||||||
let title = series_title.as_ref().unwrap_or(&String::new()).to_owned();
|
let title = series_title.as_ref().unwrap_or(&String::new()).to_owned();
|
||||||
|
let languages_string = languages
|
||||||
|
.iter()
|
||||||
|
.map(|lang| lang.name.to_owned())
|
||||||
|
.collect::<Vec<String>>()
|
||||||
|
.join(", ");
|
||||||
|
|
||||||
Row::new(vec![
|
Row::new(vec![
|
||||||
Cell::from(title),
|
Cell::from(title),
|
||||||
Cell::from(source_title.to_owned()),
|
Cell::from(source_title.to_owned()),
|
||||||
Cell::from(language.name.to_owned()),
|
Cell::from(languages_string),
|
||||||
Cell::from(quality.quality.name.to_owned()),
|
Cell::from(quality.quality.name.to_owned()),
|
||||||
Cell::from(date.to_string()),
|
Cell::from(date.to_string()),
|
||||||
])
|
])
|
||||||
|
|||||||
Reference in New Issue
Block a user