mirror of
https://github.com/MbinOrg/mbin-website.git
synced 2025-06-30 07:08:54 +00:00
Add outdated field to Releases interface
This commit is contained in:
parent
dbf4d81075
commit
e9aa425dde
2 changed files with 10 additions and 12 deletions
|
@ -12,8 +12,12 @@ const fetchReleases = async () => {
|
||||||
).json();
|
).json();
|
||||||
|
|
||||||
/** @type {Array<import('./routes/releases').Release>} */
|
/** @type {Array<import('./routes/releases').Release>} */
|
||||||
const output = releasesJson.map((v) => ({
|
const output = releasesJson.map((v, i, a) => ({
|
||||||
version: v.tag_name.substring(1),
|
version: v.tag_name.substring(1),
|
||||||
|
// A server is considered outdated if a newer version has been available for more than 30 days.
|
||||||
|
outdated:
|
||||||
|
i > 0 &&
|
||||||
|
Date.now() - Date.parse(a[i - 1].published_at) > 1000 * 60 * 60 * 24 * 30,
|
||||||
publishedAt: v.published_at,
|
publishedAt: v.published_at,
|
||||||
githubUrl: v.html_url,
|
githubUrl: v.html_url,
|
||||||
body: v.body,
|
body: v.body,
|
||||||
|
@ -141,20 +145,13 @@ const fetchServerInfo = async (domain) => {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const version = jsonNodeInfo.software.version;
|
|
||||||
|
|
||||||
// A server is considered outdated if a newer version has been available for more than 30 days.
|
|
||||||
const releaseIndex = releases.findIndex((v) => v.version === version);
|
|
||||||
const versionOutdated =
|
|
||||||
releaseIndex > 0 &&
|
|
||||||
Date.now() - Date.parse(releases[releaseIndex - 1].publishedAt) >
|
|
||||||
1000 * 60 * 60 * 24 * 30;
|
|
||||||
|
|
||||||
/** @type {import('./routes/servers').Server} */
|
/** @type {import('./routes/servers').Server} */
|
||||||
const output = {
|
const output = {
|
||||||
domain: domain,
|
domain: domain,
|
||||||
version: version,
|
version: jsonNodeInfo.software.version,
|
||||||
versionOutdated: versionOutdated,
|
versionOutdated: releases.find(
|
||||||
|
(v) => v.version === jsonNodeInfo.software.version,
|
||||||
|
).outdated,
|
||||||
name: jsonNodeInfo.metadata.nodeName,
|
name: jsonNodeInfo.metadata.nodeName,
|
||||||
description: jsonNodeInfo.metadata.nodeDescription,
|
description: jsonNodeInfo.metadata.nodeDescription,
|
||||||
openRegistrations: jsonNodeInfo.openRegistrations,
|
openRegistrations: jsonNodeInfo.openRegistrations,
|
||||||
|
|
|
@ -14,6 +14,7 @@ const releases = releasesJson as Release[];
|
||||||
|
|
||||||
export interface Release {
|
export interface Release {
|
||||||
version: string;
|
version: string;
|
||||||
|
outdated: boolean;
|
||||||
publishedAt: string;
|
publishedAt: string;
|
||||||
githubUrl: string;
|
githubUrl: string;
|
||||||
body: string;
|
body: string;
|
||||||
|
|
Loading…
Add table
Reference in a new issue