mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core&judge: probe compiler versions
This commit is contained in:
6 files changed
+94
-9
No files matched your search
@@ -25,11 +25,41 @@ async function getStatus() {
|
||||
class StatusHandler extends Handler {
|
||||
async get() {
|
||||
const stats = await getStatus();
|
||||
const compilers = {};
|
||||
const warn = {};
|
||||
const result: Array<{ key: string[], message: string }> = [];
|
||||
// For each language, select the most common compiler message version,
|
||||
// then merge languages with the same message.
|
||||
for (const stat of stats) {
|
||||
if (!stat.battery.hasBattery) stat.battery = 'No battery';
|
||||
if (!stat.battery?.hasBattery) stat.battery = 'No battery';
|
||||
else stat.battery = `${stat.battery.type} ${stat.battery.model} ${stat.battery.percent}%${stat.battery.isCharging ? ' Charging' : ''}`;
|
||||
if (stat.compilers) {
|
||||
for (const key in stat.compilers) {
|
||||
if (!compilers[key]) compilers[key] ||= [];
|
||||
const related = compilers[key].find((i) => i.message === stat.compilers[key]);
|
||||
if (related) related.related.push(stat._id);
|
||||
else {
|
||||
compilers[key].push({
|
||||
related: [stat._id],
|
||||
message: stat.compilers[key],
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.response.body = { stats };
|
||||
for (const key in compilers) {
|
||||
compilers[key].sort((a, b) => b.related.length - a.related.length);
|
||||
const message = compilers[key][0].message;
|
||||
for (let i = 1; i < compilers[key].length; i++) {
|
||||
for (const id of compilers[key][i].related) {
|
||||
warn[id] = true;
|
||||
}
|
||||
}
|
||||
const t = result.find((i) => i.message === message);
|
||||
if (t) t.key.push(key);
|
||||
else result.push({ key: [key], message });
|
||||
}
|
||||
this.response.body = { stats, compilers: result };
|
||||
this.response.template = 'status.html';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user