fix: Refactored how quality profiles, language profiles, and metadata profiles are populated for each servarr so they sort using the ID to mimic the web UI better

This commit is contained in:
Dark-Alex-17 committed 2026-01-08 10:05:15 -07:00
1 parent 1a43d1ec7c
commit ca208ff5e4
6 files changed
+58 -37

No files matched your search

@@ -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!(