Updated Ratatui, created custom deserialization logic for i64s to make life easier, and used string interpolation where possible to reduce the lines needed to write log messages or create formatted text

This commit is contained in:
2023-09-07 17:20:38 -06:00
parent e13d1ece58
commit b16a58deae
43 changed files with 426 additions and 536 deletions
+5 -5
View File
@@ -51,7 +51,7 @@ pub(super) const TASK_TABLE_CONSTRAINTS: [Constraint; 5] = [
Constraint::Percentage(22),
];
pub(super) struct SystemUi {}
pub(super) struct SystemUi;
impl DrawUi for SystemUi {
fn accepts(route: Route) -> bool {
@@ -151,7 +151,7 @@ pub(super) fn draw_queued_events<B: Backend>(f: &mut Frame<'_, B>, app: &mut App
|event| {
let queued = convert_to_minutes_hours_days(Utc::now().sub(event.queued).num_minutes());
let queued_string = if queued != "now" {
format!("{} ago", queued)
format!("{queued} ago")
} else {
queued
};
@@ -160,7 +160,7 @@ pub(super) fn draw_queued_events<B: Backend>(f: &mut Frame<'_, B>, app: &mut App
convert_to_minutes_hours_days(Utc::now().sub(event.started.unwrap()).num_minutes());
if started != "now" {
format!("{} ago", started)
format!("{started} ago")
} else {
started
}
@@ -237,14 +237,14 @@ pub(super) struct TaskProps {
}
pub(super) fn extract_task_props(task: &Task) -> TaskProps {
let interval = convert_to_minutes_hours_days(*task.interval.as_i64().as_ref().unwrap());
let interval = convert_to_minutes_hours_days(task.interval);
let last_duration = &task.last_duration[..8];
let next_execution =
convert_to_minutes_hours_days((task.next_execution - Utc::now()).num_minutes());
let last_execution =
convert_to_minutes_hours_days((Utc::now() - task.last_execution).num_minutes());
let last_execution_string = if last_execution != "now" {
format!("{} ago", last_execution)
format!("{last_execution} ago")
} else {
last_execution
};
+1 -1
View File
@@ -24,7 +24,7 @@ use crate::ui::{
#[path = "system_details_ui_tests.rs"]
mod system_details_ui_tests;
pub(super) struct SystemDetailsUi {}
pub(super) struct SystemDetailsUi;
impl DrawUi for SystemDetailsUi {
fn accepts(route: Route) -> bool {