Lidarr support #1
@@ -11,6 +11,7 @@ use crate::models::{
|
||||
use crate::network::lidarr_network::LidarrEvent;
|
||||
use bimap::BiMap;
|
||||
use chrono::{DateTime, Utc};
|
||||
use itertools::Itertools;
|
||||
use strum::EnumIter;
|
||||
#[cfg(test)]
|
||||
use {
|
||||
@@ -68,17 +69,23 @@ impl LidarrData<'_> {
|
||||
}
|
||||
|
||||
pub fn sorted_quality_profile_names(&self) -> Vec<String> {
|
||||
let mut quality_profile_names: Vec<String> =
|
||||
self.quality_profile_map.right_values().cloned().collect();
|
||||
quality_profile_names.sort();
|
||||
quality_profile_names
|
||||
self
|
||||
.quality_profile_map
|
||||
.iter()
|
||||
.sorted_by_key(|(id, _)| *id)
|
||||
.map(|(_, name)| name)
|
||||
.cloned()
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn sorted_metadata_profile_names(&self) -> Vec<String> {
|
||||
let mut metadata_profile_names: Vec<String> =
|
||||
self.metadata_profile_map.right_values().cloned().collect();
|
||||
metadata_profile_names.sort();
|
||||
metadata_profile_names
|
||||
self
|
||||
.metadata_profile_map
|
||||
.iter()
|
||||
.sorted_by_key(|(id, _)| *id)
|
||||
.map(|(_, name)| name)
|
||||
.cloned()
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -64,17 +64,17 @@ mod tests {
|
||||
#[test]
|
||||
fn test_sorted_quality_profile_names() {
|
||||
let mut quality_profile_map = BiMap::new();
|
||||
quality_profile_map.insert(3, "test 3".to_owned());
|
||||
quality_profile_map.insert(3, "test 1".to_owned());
|
||||
quality_profile_map.insert(2, "test 2".to_owned());
|
||||
quality_profile_map.insert(1, "test 1".to_owned());
|
||||
quality_profile_map.insert(1, "test 3".to_owned());
|
||||
let lidarr_data = LidarrData {
|
||||
quality_profile_map,
|
||||
..LidarrData::default()
|
||||
};
|
||||
let expected_quality_profile_vec = vec![
|
||||
"test 1".to_owned(),
|
||||
"test 2".to_owned(),
|
||||
"test 3".to_owned(),
|
||||
"test 2".to_owned(),
|
||||
"test 1".to_owned(),
|
||||
];
|
||||
|
||||
assert_iter_eq!(
|
||||
@@ -86,17 +86,17 @@ mod tests {
|
||||
#[test]
|
||||
fn test_sorted_metadata_profile_names() {
|
||||
let mut metadata_profile_map = BiMap::new();
|
||||
metadata_profile_map.insert(3, "test 3".to_owned());
|
||||
metadata_profile_map.insert(3, "test 1".to_owned());
|
||||
metadata_profile_map.insert(2, "test 2".to_owned());
|
||||
metadata_profile_map.insert(1, "test 1".to_owned());
|
||||
metadata_profile_map.insert(1, "test 3".to_owned());
|
||||
let lidarr_data = LidarrData {
|
||||
metadata_profile_map,
|
||||
..LidarrData::default()
|
||||
};
|
||||
let expected_metadata_profile_vec = vec![
|
||||
"test 1".to_owned(),
|
||||
"test 2".to_owned(),
|
||||
"test 3".to_owned(),
|
||||
"test 2".to_owned(),
|
||||
"test 1".to_owned(),
|
||||
];
|
||||
|
||||
assert_iter_eq!(
|
||||
|
||||
@@ -23,6 +23,7 @@ use crate::models::{
|
||||
use crate::network::radarr_network::RadarrEvent;
|
||||
use bimap::BiMap;
|
||||
use chrono::{DateTime, Utc};
|
||||
use itertools::Itertools;
|
||||
use serde_json::Number;
|
||||
use strum::EnumIter;
|
||||
#[cfg(test)]
|
||||
@@ -112,9 +113,13 @@ impl RadarrData<'_> {
|
||||
}
|
||||
|
||||
pub fn sorted_quality_profile_names(&self) -> Vec<String> {
|
||||
let mut names: Vec<String> = self.quality_profile_map.right_values().cloned().collect();
|
||||
names.sort();
|
||||
names
|
||||
self
|
||||
.quality_profile_map
|
||||
.iter()
|
||||
.sorted_by_key(|(id, _)| *id)
|
||||
.map(|(_, name)| name)
|
||||
.cloned()
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -82,17 +82,17 @@ mod tests {
|
||||
#[test]
|
||||
fn test_sorted_quality_profile_names() {
|
||||
let mut quality_profile_map = BiMap::new();
|
||||
quality_profile_map.insert(3, "test 3".to_owned());
|
||||
quality_profile_map.insert(3, "test 1".to_owned());
|
||||
quality_profile_map.insert(2, "test 2".to_owned());
|
||||
quality_profile_map.insert(1, "test 1".to_owned());
|
||||
quality_profile_map.insert(1, "test 3".to_owned());
|
||||
let radarr_data = RadarrData {
|
||||
quality_profile_map,
|
||||
..RadarrData::default()
|
||||
};
|
||||
let expected_quality_profile_vec = vec![
|
||||
"test 1".to_owned(),
|
||||
"test 2".to_owned(),
|
||||
"test 3".to_owned(),
|
||||
"test 2".to_owned(),
|
||||
"test 1".to_owned(),
|
||||
];
|
||||
|
||||
assert_iter_eq!(
|
||||
|
||||
@@ -25,6 +25,7 @@ use crate::{
|
||||
};
|
||||
use bimap::BiMap;
|
||||
use chrono::{DateTime, Utc};
|
||||
use itertools::Itertools;
|
||||
use serde_json::Number;
|
||||
use strum::EnumIter;
|
||||
#[cfg(test)]
|
||||
@@ -119,15 +120,23 @@ impl SonarrData<'_> {
|
||||
}
|
||||
|
||||
pub fn sorted_quality_profile_names(&self) -> Vec<String> {
|
||||
let mut names: Vec<String> = self.quality_profile_map.right_values().cloned().collect();
|
||||
names.sort();
|
||||
names
|
||||
self
|
||||
.quality_profile_map
|
||||
.iter()
|
||||
.sorted_by_key(|(id, _)| *id)
|
||||
.map(|(_, name)| name)
|
||||
.cloned()
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn sorted_language_profile_names(&self) -> Vec<String> {
|
||||
let mut names: Vec<String> = self.language_profiles_map.right_values().cloned().collect();
|
||||
names.sort();
|
||||
names
|
||||
self
|
||||
.language_profiles_map
|
||||
.iter()
|
||||
.sorted_by_key(|(id, _)| *id)
|
||||
.map(|(_, name)| name)
|
||||
.cloned()
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -98,17 +98,17 @@ mod tests {
|
||||
#[test]
|
||||
fn test_sorted_quality_profile_names() {
|
||||
let mut quality_profile_map = BiMap::new();
|
||||
quality_profile_map.insert(3, "test 3".to_owned());
|
||||
quality_profile_map.insert(3, "test 1".to_owned());
|
||||
quality_profile_map.insert(2, "test 2".to_owned());
|
||||
quality_profile_map.insert(1, "test 1".to_owned());
|
||||
quality_profile_map.insert(1, "test 3".to_owned());
|
||||
let sonarr_data = SonarrData {
|
||||
quality_profile_map,
|
||||
..SonarrData::default()
|
||||
};
|
||||
let expected_quality_profile_vec = vec![
|
||||
"test 1".to_owned(),
|
||||
"test 2".to_owned(),
|
||||
"test 3".to_owned(),
|
||||
"test 2".to_owned(),
|
||||
"test 1".to_owned(),
|
||||
];
|
||||
|
||||
assert_iter_eq!(
|
||||
@@ -120,17 +120,17 @@ mod tests {
|
||||
#[test]
|
||||
fn test_sorted_language_profile_names() {
|
||||
let mut language_profiles_map = BiMap::new();
|
||||
language_profiles_map.insert(3, "test 3".to_owned());
|
||||
language_profiles_map.insert(3, "test 1".to_owned());
|
||||
language_profiles_map.insert(2, "test 2".to_owned());
|
||||
language_profiles_map.insert(1, "test 1".to_owned());
|
||||
language_profiles_map.insert(1, "test 3".to_owned());
|
||||
let sonarr_data = SonarrData {
|
||||
language_profiles_map,
|
||||
..SonarrData::default()
|
||||
};
|
||||
let expected_language_profiles_vec = vec![
|
||||
"test 1".to_owned(),
|
||||
"test 2".to_owned(),
|
||||
"test 3".to_owned(),
|
||||
"test 2".to_owned(),
|
||||
"test 1".to_owned(),
|
||||
];
|
||||
|
||||
assert_iter_eq!(
|
||||
|
||||
Reference in New Issue
Block a user