Improve homepage demo list

This commit is contained in:
Lol3rrr
2024-10-16 12:48:02 +02:00
parent 2f29c9ea67
commit 69139261cc
7 changed files with 110 additions and 4 deletions

View File

@@ -16,7 +16,7 @@ tracing = { version = "0.1.40", features = ["async-await"] }
tracing-subscriber = "0.3.18"
futures-util = "0.3"
diesel = { version = "2.2", features = ["serde_json"] }
diesel = { version = "2.2", features = ["serde_json", "chrono"] }
diesel-async = { version = "0.5", features = ["postgres"] }
serde_json = "1.0.128"
diesel_async_migrations = { version = "0.15" }
@@ -36,3 +36,5 @@ clap = { version = "4.5", features = ["derive"] }
phf = { version = "0.11", features = ["macros"] }
uuid = { version = "1.10", features = ["v7"] }
chrono = { version = "0.4", features = ["serde"] }

View File

@@ -68,6 +68,7 @@ async fn list(
.or_insert(common::BaseDemoInfo {
id: demo.demo_id,
map: info.map,
uploaded_at: demo.uploaded_at,
team2_score: 0,
team3_score: 0,
});
@@ -81,9 +82,9 @@ async fn list(
}
}
// TODO
// Sort this
let mut output = demos.into_values().collect::<Vec<_>>();
output.sort_unstable_by_key(|d| d.uploaded_at);
Ok(axum::response::Json(output))
}

View File

@@ -23,7 +23,7 @@ pub struct NewDemo {
pub struct Demo {
pub steam_id: String,
pub demo_id: String,
pub uploaded_at: diesel::data_types::PgTimestamp,
pub uploaded_at: chrono::naive::NaiveDateTime,
}
#[derive(Queryable, Selectable, Insertable, Debug)]