sort matches descending in time

This commit is contained in:
Ilion Beyst 2021-12-28 15:04:37 +01:00
parent dacc05a41b
commit 51b52db78b

View file

@ -14,7 +14,7 @@ use std::{
fs, fs,
io::{self, BufRead}, io::{self, BufRead},
net::SocketAddr, net::SocketAddr,
path::{self, PathBuf}, path,
sync::Arc, sync::Arc,
}; };
@ -79,7 +79,7 @@ struct MatchData {
} }
async fn list_matches(Extension(state): Extension<Arc<State>>) -> Json<Vec<MatchData>> { async fn list_matches(Extension(state): Extension<Arc<State>>) -> Json<Vec<MatchData>> {
let matches = state let mut matches = state
.workspace .workspace
.matches_dir() .matches_dir()
.read_dir() .read_dir()
@ -89,6 +89,11 @@ async fn list_matches(Extension(state): Extension<Arc<State>>) -> Json<Vec<Match
get_match_data(&entry).ok() get_match_data(&entry).ok()
}) })
.collect::<Vec<_>>(); .collect::<Vec<_>>();
matches.sort_by(|a, b| {
let a = a.meta.timestamp;
let b = b.meta.timestamp;
a.cmp(&b).reverse()
});
Json(matches) Json(matches)
} }