diff --git a/src/main.rs b/src/main.rs index 73c70a0..a3091ec 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,6 +4,9 @@ use rouille::router; mod db; mod project; +// Projects not modified in this many seconds are considered stale +const STALE_AGE: i64 = 30 * 24 * 60 * 60; // 30 days in seconds + fn main() { println!("Starting server on localhost:8080"); @@ -29,7 +32,17 @@ fn main() { fn display_projects() -> rouille::Response { let projects = db::list_all_projects().unwrap_or_default(); - let active_projects: Vec<_> = projects.iter().filter(|p| !p.archived).collect(); + let now = std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .unwrap() + .as_secs() as i64; + + let active_projects: Vec<_> = projects.iter() + .filter(|p| !p.archived && (now - p.last_modified_time) <= STALE_AGE) + .collect(); + let stale_projects: Vec<_> = projects.iter() + .filter(|p| !p.archived && (now - p.last_modified_time) > STALE_AGE) + .collect(); let archived_projects: Vec<_> = projects.iter().filter(|p| p.archived).collect(); let markup = html! { @@ -51,6 +64,17 @@ fn display_projects() -> rouille::Response { archived=(project.archived) {} } } + details { + summary { "Stale" } + section { + @for project in &stale_projects { + project-card + title=(project.title) + percentage=(project.percentage_completed) + archived=(project.archived) {} + } + } + } details { summary { "Archived" } section {