Skip to content

Only show most recent beta on dashboard #695

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 20, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions site/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,27 @@ pub async fn handle_dashboard(data: Arc<InputData>) -> ServerResult<dashboard::R
(_, _) => {
use std::cmp::Ordering;

if a.starts_with("beta") && b.starts_with("beta") {
a.cmp(b)
if a.starts_with("beta-") && b.starts_with("beta-") {
let a_date = a
.strip_prefix("beta-")
.unwrap()
.parse::<chrono::NaiveDate>();
let b_date = b
.strip_prefix("beta-")
.unwrap()
.parse::<chrono::NaiveDate>();
if let (Some(a), Some(b)) = (a_date.ok(), b_date.ok()) {
a.cmp(&b)
} else {
log::error!(
"Parse failed: {:?} => {:?}, {:?} => {:?}",
a,
a_date,
b,
b_date
);
Ordering::Equal
}
} else if a.starts_with("beta") {
Ordering::Greater
} else if b.starts_with("beta") {
Expand All @@ -124,6 +143,15 @@ pub async fn handle_dashboard(data: Arc<InputData>) -> ServerResult<dashboard::R
}
}
});
let first_beta = versions.iter().position(|v| v.starts_with("beta-"));
if let Some(first_beta) = first_beta {
let last_beta = versions
.iter()
.rposition(|v| v.starts_with("beta-"))
.unwrap();
// Remove all but the latest beta version, which is the most recent.
versions.drain(first_beta..last_beta);
}

let cids = Arc::new(
versions
Expand Down