mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
core: judgeCount meter
This commit is contained in:
1 parent
1a4fcd6433
commit
ea427a112a
2 files changed
+8
-1
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "2.36.6",
|
||||
"version": "2.36.7",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "src/loader",
|
||||
"module": "src/loader",
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user