mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
core: add logger for task
This commit is contained in:
1 parent
3af3453166
commit
b3aa0a5e09
5 files changed
+7
-3
No files matched your search
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@hydrooj/hydrojudge",
|
||||
"bin": "bin/hydrojudge.js",
|
||||
"version": "2.1.9",
|
||||
"version": "2.1.10",
|
||||
"main": "package.json",
|
||||
"author": "masnn",
|
||||
"dependencies": {
|
||||
|
||||
@@ -193,7 +193,7 @@ async function readAutoCases(folder, { next }) {
|
||||
return config;
|
||||
}
|
||||
|
||||
export async function readYamlCases(folder: string, cfg: Dictionary<any>, args) {
|
||||
export async function readYamlCases(folder: string, cfg: Dictionary<any> = {}, args) {
|
||||
const config: any = {
|
||||
checker_type: 'default',
|
||||
count: 0,
|
||||
|
||||
@@ -187,6 +187,7 @@ async function postInit() {
|
||||
this.stat = {};
|
||||
this.stat.receive = new Date();
|
||||
this.request = request;
|
||||
logger.debug('%o', request);
|
||||
}
|
||||
|
||||
async handle() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "2.13.28",
|
||||
"version": "2.13.29",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "dist/loader.js",
|
||||
"typings": "dist/loader.d.ts",
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import moment from 'moment-timezone';
|
||||
import { FilterQuery, ObjectID } from 'mongodb';
|
||||
import { Task } from '../interface';
|
||||
import { Logger } from '../logger';
|
||||
import * as db from '../service/db';
|
||||
|
||||
const logger = new Logger('model/task');
|
||||
const coll = db.collection('task');
|
||||
|
||||
export async function add(task: Partial<Task> & { type: string }) {
|
||||
@@ -34,6 +36,7 @@ export async function getFirst(query: FilterQuery<Task>) {
|
||||
q.executeAfter = q.executeAfter || { $lt: new Date() };
|
||||
const res = await coll.findOneAndDelete(q);
|
||||
if (res.value) {
|
||||
logger.debug('%o', res.value);
|
||||
if (res.value.interval) {
|
||||
await coll.insertOne({
|
||||
...res.value, executeAfter: moment().add(...res.value.interval).toDate(),
|
||||
|
||||
Reference in new issue
Block a user