mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
core: judge count meter
This commit is contained in:
1 parent
d8bfbb0a22
commit
130fbcc2dd
3 files changed
+17
-8
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "2.39.24",
|
||||
"version": "2.39.25",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "src/loader",
|
||||
"module": "src/loader",
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { ObjectID } from 'mongodb';
|
||||
import tx2 from 'tx2';
|
||||
import { JudgeResultBody, RecordDoc, TestCase } from '../interface';
|
||||
import difficultyAlgorithm from '../lib/difficulty';
|
||||
import { Logger } from '../logger';
|
||||
@@ -20,11 +19,6 @@ 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;
|
||||
@@ -86,7 +80,6 @@ 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;
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import crypto from 'crypto';
|
||||
import { dump } from 'js-yaml';
|
||||
import superagent from 'superagent';
|
||||
import tx2 from 'tx2';
|
||||
import type { StatusUpdate } from '@hydrooj/utils/lib/sysinfo';
|
||||
import * as sysinfo from '@hydrooj/utils/lib/sysinfo';
|
||||
import { Time } from '@hydrooj/utils/lib/utils';
|
||||
import { Logger } from '../logger';
|
||||
import * as bus from './bus';
|
||||
import db from './db';
|
||||
@@ -96,6 +98,20 @@ if (process.env.NODE_APP_INSTANCE === '0') {
|
||||
feedback();
|
||||
setInterval(update, 60 * 1000);
|
||||
});
|
||||
const taskColl = db.collection('task');
|
||||
let taskCount = await taskColl.find().count();
|
||||
const recordColl = db.collection('record');
|
||||
let recordCount = await recordColl.find({
|
||||
_id: { $gte: Time.getObjectID(new Date(Date.now() - 60 * 1000)) },
|
||||
}).count();
|
||||
tx2.metric('task', () => taskCount);
|
||||
tx2.metric('submission', () => recordCount);
|
||||
setInterval(() => {
|
||||
taskColl.find().count().then((c) => { taskCount = c; });
|
||||
recordColl.find({
|
||||
_id: { $gte: Time.getObjectID(new Date(Date.now() - 60 * 1000)) },
|
||||
}).count().then((c) => { recordCount = c; });
|
||||
}, 1000);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user