Skip to content

Commit a7c1347

Browse files
Merge pull request #695 from Mark-Simulacrum/only-last-beta
Only show most recent beta on dashboard
2 parents 59d91b8 + 0a17e5a commit a7c1347

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

site/src/server.rs

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,27 @@ pub async fn handle_dashboard(data: Arc<InputData>) -> ServerResult<dashboard::R
110110
(_, _) => {
111111
use std::cmp::Ordering;
112112

113-
if a.starts_with("beta") && b.starts_with("beta") {
114-
a.cmp(b)
113+
if a.starts_with("beta-") && b.starts_with("beta-") {
114+
let a_date = a
115+
.strip_prefix("beta-")
116+
.unwrap()
117+
.parse::<chrono::NaiveDate>();
118+
let b_date = b
119+
.strip_prefix("beta-")
120+
.unwrap()
121+
.parse::<chrono::NaiveDate>();
122+
if let (Some(a), Some(b)) = (a_date.ok(), b_date.ok()) {
123+
a.cmp(&b)
124+
} else {
125+
log::error!(
126+
"Parse failed: {:?} => {:?}, {:?} => {:?}",
127+
a,
128+
a_date,
129+
b,
130+
b_date
131+
);
132+
Ordering::Equal
133+
}
115134
} else if a.starts_with("beta") {
116135
Ordering::Greater
117136
} else if b.starts_with("beta") {
@@ -124,6 +143,15 @@ pub async fn handle_dashboard(data: Arc<InputData>) -> ServerResult<dashboard::R
124143
}
125144
}
126145
});
146+
let first_beta = versions.iter().position(|v| v.starts_with("beta-"));
147+
if let Some(first_beta) = first_beta {
148+
let last_beta = versions
149+
.iter()
150+
.rposition(|v| v.starts_with("beta-"))
151+
.unwrap();
152+
// Remove all but the latest beta version, which is the most recent.
153+
versions.drain(first_beta..last_beta);
154+
}
127155

128156
let cids = Arc::new(
129157
versions

0 commit comments

Comments
 (0)