core: judgeCount meter

This commit is contained in:
undefined committed 2021-09-19 19:18:47 +08:00
1 parent 1a4fcd6433
commit ea427a112a
2 files changed
+8 -1

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "2.36.6",
"version": "2.36.7",
"bin": "bin/hydrooj.js",
"main": "src/loader",
"module": "src/loader",
+7
View File
@@ -1,4 +1,5 @@
import { ObjectID } from 'mongodb';
import tx2 from 'tx2';
import { JudgeResultBody, RecordDoc, TestCase } from '../interface';
import difficultyAlgorithm from '../lib/difficulty';
import { Logger } from '../logger';
@@ -19,6 +20,11 @@ import {
import { sleep } from '../utils';
const logger = new Logger('judge');
const judgeCount = tx2.meter({
name: 'judge/min',
samples: 60,
timeframe: 120,
});
export async function postJudge(rdoc: RecordDoc) {
if (typeof rdoc.input === 'string') return;
@@ -79,6 +85,7 @@ export async function next(body: JudgeResultBody) {
}
export async function end(body: JudgeResultBody) {
judgeCount.mark();
if (body.rid) body.rid = new ObjectID(body.rid);
let rdoc = await record.get(body.rid);
if (!rdoc) return;