+nginx.conf; update scratchpad

This commit is contained in:
undefined committed 2020-07-16 15:18:55 +08:00
1 parent 6ad41dc2ae
commit 2d5eef8d08
28 files changed
+206 -230

No files matched your search

+6 -1
View File
@@ -18,6 +18,7 @@ import * as system from '../model/system';
import {
Route, Handler, Types, param,
} from '../service/server';
import * as bus from '../service/bus';
const ContestHandler = contest.ContestHandlerMixin(Handler);
@@ -281,7 +282,11 @@ class ContestProblemSubmitHandler extends ContestProblemHandler {
lang,
code,
}, true);
await contest.updateStatus(domainId, this.tdoc.docId, this.user._id, rid, this.pdoc.docId);
const [rdoc] = await Promise.all([
record.get(domainId, rid),
contest.updateStatus(domainId, this.tdoc.docId, this.user._id, rid, this.pdoc.docId),
]);
bus.publish('record_change', rdoc);
if (!this.canShowRecord(this.tdoc)) {
this.response.body = { tid };
this.response.redirect = this.url('contest_detail', { tid });
+8 -3
View File
@@ -11,6 +11,7 @@ import { PenaltyRules } from '../interface';
import {
Route, Handler, Types, param,
} from '../service/server';
import * as bus from '../service/bus';
import { PERM } from '../model/builtin';
import * as system from '../model/system';
import * as user from '../model/user';
@@ -175,7 +176,7 @@ class HomeworkDetailProblemSubmitHandler extends HomeworkDetailProblemHandler {
@param('code', Types.String)
@param('lang', Types.String)
async post(domainId: string, tid: ObjectID, pid: number, code: string, lang: string) {
this.limitRate('add_record', 60, 100);
this.limitRate('add_record', 3600, 100);
const tsdoc = await contest.getStatus(domainId, tid, this.user._id, document.TYPE_HOMEWORK);
if (!tsdoc.attend) throw new HomeworkNotAttendedError(tid);
if (!contest.isOngoing(this.tdoc)) throw new HomeworkNotLiveError(tid);
@@ -183,8 +184,12 @@ class HomeworkDetailProblemSubmitHandler extends HomeworkDetailProblemHandler {
const rid = await record.add(domainId, {
pid, lang, code, uid: this.user._id, tid, hidden: true, ttype: document.TYPE_HOMEWORK,
}, true);
await contest.updateStatus(domainId, tid, this.user._id,
rid, pid, false, 0, document.TYPE_HOMEWORK);
const [rdoc] = await Promise.all([
record.get(domainId, rid),
contest.updateStatus(domainId, tid, this.user._id,
rid, pid, false, 0, document.TYPE_HOMEWORK),
]);
bus.publish('record_change', rdoc);
this.response.body = { tid, rid };
if (this.canShowRecord(this.tdoc)) this.response.redirect = this.url('record_detail', { rid });
else this.response.redirect = this.url('homework_detail', { tid });
+1
View File
@@ -140,6 +140,7 @@ class UiSettingsHandler extends Handler {
header_background_2x,
});
this.response.type = 'text/css';
this.ctx.set('nolog', '1');
}
}
+18 -10
View File
@@ -19,6 +19,7 @@ import {
import {
NoProblemError, ProblemDataNotFoundError, BadRequestError,
SolutionNotFoundError,
ProblemNotFoundError,
} from '../error';
import { Pdoc, User, Rdoc } from '../interface';
@@ -220,7 +221,11 @@ class ProblemSubmitHandler extends ProblemDetailHandler {
const rid = await record.add(domainId, {
uid: this.user._id, lang, code, pid: this.pdoc.docId,
}, true);
await domain.incUserInDomain(domainId, this.user._id, 'nSubmit');
const [rdoc] = await Promise.all([
record.get(domainId, rid),
domain.incUserInDomain(domainId, this.user._id, 'nSubmit'),
]);
bus.publish('record_change', rdoc);
this.response.body = { rid };
this.response.redirect = this.url('record_detail', { rid });
}
@@ -229,13 +234,14 @@ class ProblemSubmitHandler extends ProblemDetailHandler {
class ProblemPretestHandler extends ProblemDetailHandler {
@param('lang', Types.String)
@param('code', Types.String)
@param('input', Types.String)
async post(domainId: string, lang: string, code: string, input: string) {
this.limitRate('add_record', 60, 100);
@param('input', Types.String, true)
async post(domainId: string, lang: string, code: string, input: string = '') {
this.limitRate('add_record', 3600, 100);
const rid = await record.add(domainId, {
uid: this.user._id, lang, code, pid: this.pdoc.docId, input,
}, true);
await record.judge(domainId, rid);
const rdoc = await record.get(domainId, rid);
bus.publish('record_change', rdoc);
this.response.body = { rid };
}
}
@@ -247,7 +253,9 @@ class ProblemPretestConnectionHandler extends ConnectionHandler {
@param('pid', Types.String)
async prepare(domainId: string, pid: string) {
this.pid = pid;
const pdoc = await problem.get(domainId, pid);
if (!pdoc) throw new ProblemNotFoundError(domainId, pid);
this.pid = pdoc.docId.toString();
this.domainId = domainId;
bus.subscribe(['record_change'], this, 'onRecordChange');
}
@@ -310,11 +318,11 @@ class ProblemSettingsHandler extends ProblemManageHandler {
@param('pid', Types.String, null, parsePid)
@param('hidden', Types.Boolean)
@param('category', Types.String, null, parseCategory)
@param('tag', Types.String, null, parseCategory)
@param('category', Types.String, true, null, parseCategory)
@param('tag', Types.String, true, null, parseCategory)
async postSetting(
domainId: string, pid: string | number, hidden = false,
category: string[], tag: string[],
category: string[] = [], tag: string[] = [],
) {
const pdoc = await problem.get(domainId, pid);
await problem.edit(domainId, pdoc.docId, { hidden, category, tag });
@@ -554,7 +562,7 @@ export async function apply() {
Route('problem_solution_raw', '/p/:pid/solution/:psid/raw', ProblemSolutionRawHandler);
Route('problem_solution_reply_raw', '/p/:pid/solution/:psid/:psrid/raw', ProblemSolutionReplyRawHandler);
Route('problem_create', '/problem/create', ProblemCreateHandler);
Connection('problem_pretest_conn', '/p/:pid/pretest-conn', ProblemPretestConnectionHandler);
Connection('problem_pretest_conn', '/conn/pretest', ProblemPretestConnectionHandler);
}
global.Hydro.handler.problem = apply;