diff options
author | Ilion Beyst <ilion.beyst@gmail.com> | 2021-12-28 15:04:37 +0100 |
---|---|---|
committer | Ilion Beyst <ilion.beyst@gmail.com> | 2021-12-28 15:04:37 +0100 |
commit | 51b52db78bed6585702e4bd761bb17018f5a0247 (patch) | |
tree | c4bbd5cea6a9a7211b67563e919892f48ec83ff3 /planetwars-cli/src/web | |
parent | dacc05a41b77bf2e86e27ac354db9b047c661a7d (diff) | |
download | planetwars.dev-51b52db78bed6585702e4bd761bb17018f5a0247.tar.xz planetwars.dev-51b52db78bed6585702e4bd761bb17018f5a0247.zip |
sort matches descending in time
Diffstat (limited to 'planetwars-cli/src/web')
-rw-r--r-- | planetwars-cli/src/web/mod.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/planetwars-cli/src/web/mod.rs b/planetwars-cli/src/web/mod.rs index 676d7af..a0e452e 100644 --- a/planetwars-cli/src/web/mod.rs +++ b/planetwars-cli/src/web/mod.rs @@ -14,7 +14,7 @@ use std::{ fs, io::{self, BufRead}, net::SocketAddr, - path::{self, PathBuf}, + path, sync::Arc, }; @@ -79,7 +79,7 @@ struct MatchData { } async fn list_matches(Extension(state): Extension<Arc<State>>) -> Json<Vec<MatchData>> { - let matches = state + let mut matches = state .workspace .matches_dir() .read_dir() @@ -89,6 +89,11 @@ async fn list_matches(Extension(state): Extension<Arc<State>>) -> Json<Vec<Match get_match_data(&entry).ok() }) .collect::<Vec<_>>(); + matches.sort_by(|a, b| { + let a = a.meta.timestamp; + let b = b.meta.timestamp; + a.cmp(&b).reverse() + }); Json(matches) } |