filtered unnecesary stuff

This commit is contained in:
2025-07-19 08:48:46 -05:00
parent 395c004343
commit b40b84d58e
2 changed files with 26 additions and 3 deletions
+10 -2
View File
@@ -73,9 +73,17 @@ async fn get_apps(query: web::Query<Auth>) -> Result<impl Responder> {
units
.iter()
.map(|v| match systemctl.status(v) {
Ok(unit) => serde_json::to_value(service::parse_service(unit)).unwrap(),
Err(_) => json!({ "name": v, "status": "undefined" }),
Ok(unit) => {
let a = service::parse_service(unit);
// In the case of debugging, i found out these have a pattern of .target or .device
// if a.all_fields_none() {
// println!("\n--START--\n{v}\n--END--\n");
// }
a
}
Err(_) => service::parse_service(String::new()),
})
.filter(|i| !i.all_fields_none())
.collect::<Vec<_>>(),
)),
Err(e) => Err(actix_web::error::ErrorInternalServerError(format!(
+16 -1
View File
@@ -15,7 +15,6 @@ pub struct Service {
pub trigger: Option<String>,
pub triggers: Option<String>,
pub docs: Option<String>,
// Other fields can be added as needed
}
lazy_static! {
@@ -63,3 +62,19 @@ pub fn parse_service(input: String) -> Service {
}
}
}
impl Service {
pub fn all_fields_none(&self) -> bool {
self.name.is_none()
&& self.description.is_none()
&& self.loaded_status.is_none()
&& self.unit_file_path.is_none()
&& self.enabled.is_none()
&& self.preset.is_none()
&& self.active.is_none()
&& self.active_state.is_none()
&& self.trigger.is_none()
&& self.triggers.is_none()
&& self.docs.is_none()
}
}