From 702581f7c732dedc4247ae3709d1b607309191e5 Mon Sep 17 00:00:00 2001 From: Stephen Brennan Date: Mon, 15 Jul 2024 14:07:32 -0700 Subject: [PATCH] web: use latest git SHA for date picker As it is we are overwriting the mapping with the oldest commit on a particular date. For dates where there are multiple entries, it usually means we made some updates for a particular new version or distro. As a result, it's best to prefer the newest commit on that day, not the oldest. Let's track this and only use the newest date. We can't use the set of dates (which you'd expect we could) because the JS "Date" object is actually date + time, and commits are not likely on the exact same date and time. Signed-off-by: Stephen Brennan --- index.html | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/index.html b/index.html index 4b8fcb4..be8f07a 100644 --- a/index.html +++ b/index.html @@ -119,9 +119,18 @@ data = JSON.parse(data) let resp = Array.from(data); let dates = new Set(); + let lastDateStr = undefined; resp.forEach((res)=>{ const date = new Date(res.commit.committer.date); const dateStr = dateString(date); + + // We encounter commits in reverse chronological order. Use the + // first commit for the date and skip the rest, as we normally + // care about the most recent commit on the date. + if (dateStr === lastDateStr) + return; + lastDateStr = dateStr; + dates.add(date); versionDateMapping.set(dateStr, res.sha) // If we started with a SHA, replace it with the date string