Skip to content

Commit 0e8d684

Browse files
committed
WIP fetch commit date instead of last eval time
1 parent f445a76 commit 0e8d684

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

www/js/status.js

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,21 @@ async function fetchMetrics(queryType, queryArgs = {}) {
5454
return data.result;
5555
}
5656

57+
async function fetchCommitDate(commit) {
58+
const response = await fetch(`https://api.github.com/repos/NixOS/nixpkgs/commits/${commit}`);
59+
const data = await response.json();
60+
return moment.utc(data.commit.author.date);
61+
}
62+
63+
function fetchAllCommits(revisions) {
64+
let promises = {};
65+
for (const i = 0; i <= revisions.length; i++) {
66+
const revision = revisions[i];
67+
promises[revision] = (fetchCommitDate(revision))
68+
};
69+
return promises;
70+
}
71+
5772
const revisionData = fetchMetrics('query', {
5873
query: 'channel_revision'
5974
})
@@ -130,8 +145,15 @@ function cmp_channels(left, right) {
130145
}
131146

132147
init
133-
.then(() => Promise.all([revisionData, updateTimeData, jobsetData]))
134-
.then(([revisions, update_times, jobsets]) => {
148+
.then(() => Promise.all([revisionData, jobsetData]))
149+
.then(([revisions, jobsets]) => {
150+
const all_commits = Object.values(revisions).map((v) => v.revision);
151+
const commit_dates = fetchAllCommits(all_commits);
152+
Promise.all(Object.values(commit_dates));
153+
154+
return [revisions, commit_dates, jobsets];
155+
})
156+
.then(([revisions, commit_dates, jobsets]) => {
135157
var combined = [];
136158

137159
for (let [channel, jobset] of Object.entries(jobsets)) {
@@ -147,8 +169,10 @@ init
147169
} else {
148170
continue
149171
}
150-
if (update_times[channel] != undefined) {
151-
var m = moment.unix(update_times[channel]['update_time']);
172+
173+
const commit_date = commit_dates[revisions[channel]['revision']];
174+
if (commit_date != undefined) {
175+
var m = moment.unix(commit_date);
152176
jobset['update_time_relative'] = m.fromNow()
153177
jobset['update_time_local'] = m.format()
154178
// do not use color indications on outdated channels

0 commit comments

Comments
 (0)