refactor: Added accessor methods to servarr_data structs, replaced for loops with functional iterator chains, eliminated mutable state tracking, and updated network module to use get_or_insert_default() for modal options
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use bimap::BiMap;
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde_json::Number;
|
||||
use strum::EnumIter;
|
||||
|
||||
use crate::{
|
||||
@@ -87,6 +88,29 @@ impl SonarrData<'_> {
|
||||
self.seasons = StatefulTable::default();
|
||||
self.series_info_tabs.index = 0;
|
||||
}
|
||||
|
||||
pub fn tag_ids_to_display(&self, tag_ids: &[Number]) -> String {
|
||||
tag_ids
|
||||
.iter()
|
||||
.filter_map(|tag_id| {
|
||||
let id = tag_id.as_i64()?;
|
||||
self.tags_map.get_by_left(&id).cloned()
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.join(", ")
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Default for SonarrData<'a> {
|
||||
|
||||
Reference in New Issue
Block a user