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:
@@ -23,6 +23,7 @@ use crate::models::{
|
||||
use crate::network::radarr_network::RadarrEvent;
|
||||
use bimap::BiMap;
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde_json::Number;
|
||||
use strum::EnumIter;
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -81,6 +82,23 @@ impl RadarrData<'_> {
|
||||
self.movie_details_modal = None;
|
||||
self.movie_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
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Default for RadarrData<'a> {
|
||||
|
||||
Reference in New Issue
Block a user