bug fixes

This commit is contained in:
undefined committed 2025-03-15 06:43:18 +08:00
1 parent 4b7de2f448
commit a01c83c1b6
9 files changed
+51 -25

No files matched your search

+12 -6
View File
@@ -6,13 +6,19 @@ const { homedir } = require('os');
const { default: hook } = require('@undefined-moe/require-resolve-hook');
const { bypass } = hook(/^(hydrooj|@hydrooj|cordis|lodash|js-yaml)($|\/)/, (id) => {
if (id.startsWith('hydrooj/src')) {
console.log('module require via %s is deprecated.', id);
if (process.env.DEV) {
console.log(
new Error().stack.split('\n')
.filter((i) => !i.includes('node:internal') && i.startsWith(' '))
.join('\n'),
);
const error = new Error(`module require via ${id} is deprecated.`);
const filter = [
'node:diagnostics', 'node:internal',
'_resolveFilename', 'ignoreModuleNotFoundError',
'framework/register', '@hydrooj/register',
];
error.stack = error.stack.split('\n')
.filter((i) => !filter.some((f) => i.includes(f)))
.join('\n');
console.error(error);
} else {
console.warn('Module require via %s is deprecated.', id);
}
}
if (id.startsWith('hydrooj')) {
+1 -1
View File
@@ -42,7 +42,7 @@ class I18nService extends Service {
if (languages[0]?.startsWith('en')) {
// For most use cases, source text equals to translated text in English.
// So if it doesn't exist, we should use the original text instead of fallback.
return this.get(str, languages[0]) || this.get(str, 'en') || this.toString();
return this.get(str, languages[0]) || this.get(str, 'en') || str.toString();
}
for (const language of languages.filter(Boolean)) {
const curr = this.get(str, language) || this.get(str, language.split('_')[0])
+3 -3
View File
@@ -388,7 +388,7 @@ const oi = buildContestRule({
score: tsddict[pid]?.score,
};
if (tsddict[pid]?.status === STATUS.STATUS_ACCEPTED) {
if (tsddict[pid].rid.getTimestamp().getTime() - (tsdoc.startAt.getTime() || tdoc.beginAt.getTime())) {
if (tsddict[pid].rid.getTimestamp().getTime() - (tsdoc.startAt || tdoc.beginAt).getTime() === meta?.first?.[pid]) {
node.style = 'background-color: rgb(217, 240, 199);';
}
}
@@ -403,9 +403,9 @@ const oi = buildContestRule({
const psdict = {};
const first = {};
for (const [, tsdoc] of rankedTsdocs) {
for (const [pid, detail] of Object.entries(tsdoc.detail)) {
for (const [pid, detail] of Object.entries(tsdoc.detail || {})) {
if (detail.status !== STATUS.STATUS_ACCEPTED) continue;
const time = detail.rid.getTimestamp().getTime() - (tsdoc.startAt.getTime() || tdoc.beginAt.getTime());
const time = detail.rid.getTimestamp().getTime() - (tsdoc.startAt || tdoc.beginAt).getTime();
if (!first[pid] || first[pid] > time) first[pid] = time;
}
}
+10 -3
View File
@@ -222,15 +222,22 @@ export async function apply(ctx: Context) {
}
},
});
server.wsHandlerMixin((s) => ({
server.wsHandlerMixin({
async onerror(err: HydroError) {
if (![NotFoundError, PrivilegeError, PermissionError].some((i) => err instanceof i) || this.user?._id !== 0) {
logger.error(`Path:${this.request.path}, User:${this.user?._id}(${this.user?.uname})`);
logger.error(err);
}
await s.onerror(err);
if (err instanceof UserFacingError) err.stack = this.request.path;
this.send({
error: {
name: err.name,
params: err.params || [],
},
});
this.close(4000, err.toString());
},
}));
});
on('handler/create', async (h) => {
h.user = h.context.HydroContext.user as any;
@@ -274,6 +274,3 @@ export class TemplateService extends Service {
}
}
}
export async function apply(ctx: Context) {
}
+3 -1
View File
@@ -155,7 +155,9 @@ class AccountService {
this.syncing = false;
}
async stop() { } // eslint-disable-line @typescript-eslint/no-empty-function
async stop() {
return this.api?.stop?.();
}
async main() {
const res = await this.login();
+1
View File
@@ -41,6 +41,7 @@ export interface IBasicProvider {
submitProblem(id: string, lang: string, code: string, info: any, next: NextFunction, end: NextFunction): Promise<string | void>;
waitForSubmission(id: string, next: NextFunction, end: NextFunction): Promise<void>;
checkStatus?: (onCheckFunc: boolean) => Promise<void>;
stop?: () => Promise<void>;
}
export interface BasicProvider {