Separate stale items

This commit is contained in:
Nettika 2026-01-25 15:03:30 -08:00
parent 91bbfbd4d4
commit ce25232e06
No known key found for this signature in database

View file

@ -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 {