core: fix websocket event push

This commit is contained in:
undefined committed 2023-01-30 13:28:23 +08:00
1 parent 518915ceab
commit f834d9ca87
5 files changed
+5 -5

No files matched your search

+3
View File
@@ -1,4 +1,5 @@
import { hostname } from 'os';
import cac from 'cac';
import { FilterQuery, ObjectID } from 'mongodb';
import { nanoid } from 'nanoid';
import { sleep } from '@hydrooj/utils/lib/utils';
@@ -11,6 +12,7 @@ import db from '../service/db';
const logger = new Logger('model/task');
const coll = db.collection('task');
const collEvent = db.collection('event');
const argv = cac().parse();
async function getFirst(query: FilterQuery<Task>) {
if (process.env.CI) return null;
@@ -133,6 +135,7 @@ export async function apply(ctx: Context) {
{ expire: { $gt: new Date() }, ack: { $nin: [id] } },
{ $push: { ack: id } },
);
if (argv.options.showEvent) logger.info('Event: %o', res.value);
// eslint-disable-next-line no-await-in-loop
await (res.value ? handleEvent(res.value) : sleep(500));
}