mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-05 22:56:00 +02:00
Improve instance stats
This commit is contained in:
22
src/services/register-or-fetch-instance-doc.ts
Normal file
22
src/services/register-or-fetch-instance-doc.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import Instance, { IInstance } from '../models/instance';
|
||||
import federationChart from '../chart/federation';
|
||||
|
||||
export async function registerOrFetchInstanceDoc(host: string): Promise<IInstance> {
|
||||
if (host == null) return null;
|
||||
|
||||
const index = await Instance.findOne({ host });
|
||||
|
||||
if (index == null) {
|
||||
const i = await Instance.insert({
|
||||
host,
|
||||
caughtAt: new Date(),
|
||||
system: null // TODO
|
||||
});
|
||||
|
||||
federationChart.update(true);
|
||||
|
||||
return i;
|
||||
} else {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user