Fix invidious CI

This commit is contained in:
Ajay 2024-09-06 02:45:32 -04:00
parent c0a579e84b
commit e7eeee1b9d
2 changed files with 11 additions and 50 deletions

View file

@ -3,25 +3,21 @@ import { InvidiousInstance, instanceMap } from "./invidiousType"
import * as data from "../ci/invidious_instances.json"; import * as data from "../ci/invidious_instances.json";
// only https servers // only https servers
const mapped: instanceMap = data const mapped: instanceMap = (data as InvidiousInstance[])
.filter((i: InvidiousInstance) => i[1]?.type === "https") .filter((i) => i[1]?.type === "https")
.map((instance: InvidiousInstance) => { .map((instance) => {
return { return {
name: instance[0], name: instance[0],
url: instance[1].uri, url: instance[1].uri,
dailyRatios: instance[1].monitor.dailyRatios, uptime: instance[1].monitor?.uptime || 0,
thirtyDayUptime: instance[1]?.monitor["30dRatio"].ratio, down: instance[1].monitor?.down ?? false
} }
}); });
// reliability and sanity checks // reliability and sanity checks
const reliableCheck = mapped const reliableCheck = mapped
.filter(instance => { .filter(instance => {
// 30d uptime >= 90% return instance.uptime > 80 && !instance.down;
const thirtyDayUptime = Number(instance.thirtyDayUptime) >= 90;
// available for at least 80/90 days
const dailyRatioCheck = instance.dailyRatios.filter(status => status.label !== "black");
return thirtyDayUptime && dailyRatioCheck.length >= 80;
}) })
// url includes name // url includes name
.filter(instance => instance.url.includes(instance.name)); .filter(instance => instance.url.includes(instance.name));

View file

@ -1,54 +1,19 @@
type ratio = {
ratio: string;
label: string;
}
export type instanceMap = { export type instanceMap = {
name: string; name: string;
url: string; url: string;
dailyRatios: {ratio: string; label: string }[]; uptime: number;
thirtyDayUptime: string; down: boolean;
}[] }[]
export type InvidiousInstance = [ export type InvidiousInstance = [
string, string,
{ {
flag: string;
region: string;
stats: null | {
version: string;
software: {
name: string;
version: string;
branch: string;
};
openRegistrations: boolean;
usage: {
users: {
total: number;
activeHalfyear: number;
activeMonth: number;
};
};
metadata: {
updatedAt: number;
lastChannelRefreshedAt: number;
};
};
cors: boolean | null;
api: boolean | null;
type: "https" | "http" | "onion" | "i2p";
uri: string; uri: string;
type: "https" | "http" | "onion" | "i2p";
monitor: null | { monitor: null | {
monitorId: number; uptime: number;
createdAt: number; down: boolean;
statusClass: string;
name: string;
url: string | null;
type: "HTTP(s)";
dailyRatios: ratio[];
"90dRatio": ratio;
"30dRatio": ratio;
}; };
} }
] ]