Separate stale items
This commit is contained in:
parent
91bbfbd4d4
commit
ce25232e06
1 changed files with 25 additions and 1 deletions
26
src/main.rs
26
src/main.rs
|
|
@ -4,6 +4,9 @@ use rouille::router;
|
||||||
mod db;
|
mod db;
|
||||||
mod project;
|
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() {
|
fn main() {
|
||||||
println!("Starting server on localhost:8080");
|
println!("Starting server on localhost:8080");
|
||||||
|
|
||||||
|
|
@ -29,7 +32,17 @@ fn main() {
|
||||||
fn display_projects() -> rouille::Response {
|
fn display_projects() -> rouille::Response {
|
||||||
let projects = db::list_all_projects().unwrap_or_default();
|
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 archived_projects: Vec<_> = projects.iter().filter(|p| p.archived).collect();
|
||||||
|
|
||||||
let markup = html! {
|
let markup = html! {
|
||||||
|
|
@ -51,6 +64,17 @@ fn display_projects() -> rouille::Response {
|
||||||
archived=(project.archived) {}
|
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 {
|
details {
|
||||||
summary { "Archived" }
|
summary { "Archived" }
|
||||||
section {
|
section {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue