Improve /api/instances
This commit is contained in:
parent
08c71218b2
commit
256aa8fbd0
1 changed files with 7 additions and 3 deletions
|
@ -10,7 +10,7 @@ interface ProjectInstance {
|
||||||
domain: string;
|
domain: string;
|
||||||
score: number;
|
score: number;
|
||||||
active_users_monthly: number;
|
active_users_monthly: number;
|
||||||
status: number;
|
total_users: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const PROJECTS = Object.values(FediverseProject);
|
const PROJECTS = Object.values(FediverseProject);
|
||||||
|
@ -25,13 +25,17 @@ export const fetchInstances = async (
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
referrer: "https://api.fediverse.observer/",
|
referrer: "https://api.fediverse.observer/",
|
||||||
body: `{"query":"{\\n nodes(softwarename: \\"${projectId}\\") {\\n domain\\n score\\n active_users_monthly\\n status\\n }\\n}\\n"}`,
|
body: JSON.stringify({
|
||||||
|
query: `{nodes(status:"UP",softwarename:"${projectId}"){domain score active_users_monthly total_users}}`,
|
||||||
|
}),
|
||||||
method: "POST",
|
method: "POST",
|
||||||
});
|
});
|
||||||
const json = await response.json();
|
const json = await response.json();
|
||||||
const instances: ProjectInstance[] = json.data.nodes;
|
const instances: ProjectInstance[] = json.data.nodes;
|
||||||
return instances.filter(
|
return instances.filter(
|
||||||
(instance) => instance.score > 0 && instance.status === 1,
|
(instance) =>
|
||||||
|
instance.score > 90 &&
|
||||||
|
instance.total_users >= instance.active_users_monthly,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Reference in a new issue