Improve instance stats

This commit is contained in:
syuilo 2019-02-07 16:05:29 +09:00
parent 485f2f460e
commit 7275bc6d3b
No known key found for this signature in database
GPG Key ID: BDC4C49D06AB9D69
2 changed files with 18 additions and 2 deletions

View File

@ -44,12 +44,17 @@ export interface IInstance {
followersCount: number;
/**
*
*
*/
latestRequestSentAt?: Date;
/**
* HTTPステータス
* HTTPステータスコード
*/
latestStatus?: number;
/**
*
*/
latestRequestReceivedAt?: Date;
}

View File

@ -8,6 +8,8 @@ import { toUnicode } from 'punycode';
import { URL } from 'url';
import { publishApLogStream } from '../../../services/stream';
import Logger from '../../../misc/logger';
import { registerOrFetchInstanceDoc } from '../../../services/register-or-fetch-instance-doc';
import Instance from '../../../models/instance';
const logger = new Logger('inbox');
@ -101,6 +103,15 @@ export default async (job: bq.Job, done: any): Promise<void> => {
});
//#endregion
// Update stats
registerOrFetchInstanceDoc(user.host).then(i => {
Instance.update({ _id: i._id }, {
$set: {
latestRequestReceivedAt: new Date()
}
});
});
// アクティビティを処理
try {
await perform(user, activity);