mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: flush discussion node before re-init
This commit is contained in:
1 parent
18703533da
commit
dc4464c19a
4 files changed
+9
-3
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "2.39.14",
|
"version": "2.39.15",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "src/loader",
|
"main": "src/loader",
|
||||||
"module": "src/loader",
|
"module": "src/loader",
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ export class ContestDetailHandler extends Handler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ContestBoardcastHandler extends Handler {
|
export class ContestBroadcastHandler extends Handler {
|
||||||
@param('tid', Types.ObjectID)
|
@param('tid', Types.ObjectID)
|
||||||
async get(domainId: string, tid: ObjectID) {
|
async get(domainId: string, tid: ObjectID) {
|
||||||
const tdoc = await contest.get(domainId, tid);
|
const tdoc = await contest.get(domainId, tid);
|
||||||
@@ -435,7 +435,7 @@ export async function apply() {
|
|||||||
Route('contest_create', '/contest/create', ContestEditHandler);
|
Route('contest_create', '/contest/create', ContestEditHandler);
|
||||||
Route('contest_main', '/contest', ContestListHandler, PERM.PERM_VIEW_CONTEST);
|
Route('contest_main', '/contest', ContestListHandler, PERM.PERM_VIEW_CONTEST);
|
||||||
Route('contest_detail', '/contest/:tid', ContestDetailHandler, PERM.PERM_VIEW_CONTEST);
|
Route('contest_detail', '/contest/:tid', ContestDetailHandler, PERM.PERM_VIEW_CONTEST);
|
||||||
Route('contest_broadcast', '/contest/:tid/broadcast', ContestBoardcastHandler);
|
Route('contest_broadcast', '/contest/:tid/broadcast', ContestBroadcastHandler);
|
||||||
Route('contest_edit', '/contest/:tid/edit', ContestEditHandler, PERM.PERM_VIEW_CONTEST);
|
Route('contest_edit', '/contest/:tid/edit', ContestEditHandler, PERM.PERM_VIEW_CONTEST);
|
||||||
Route('contest_scoreboard', '/contest/:tid/scoreboard', ContestScoreboardHandler, PERM.PERM_VIEW_CONTEST);
|
Route('contest_scoreboard', '/contest/:tid/scoreboard', ContestScoreboardHandler, PERM.PERM_VIEW_CONTEST);
|
||||||
Route('contest_scoreboard_download', '/contest/:tid/export/:ext', ContestScoreboardDownloadHandler, PERM.PERM_VIEW_CONTEST);
|
Route('contest_scoreboard_download', '/contest/:tid/export/:ext', ContestScoreboardDownloadHandler, PERM.PERM_VIEW_CONTEST);
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ class DomainDashboardHandler extends ManageHandler {
|
|||||||
|
|
||||||
async postInitDiscussionNode({ domainId }) {
|
async postInitDiscussionNode({ domainId }) {
|
||||||
const nodes = load(system.get('discussion.nodes'));
|
const nodes = load(system.get('discussion.nodes'));
|
||||||
|
await discussion.flushNodes(domainId);
|
||||||
for (const category of Object.keys(nodes)) {
|
for (const category of Object.keys(nodes)) {
|
||||||
for (const item of nodes[category]) {
|
for (const item of nodes[category]) {
|
||||||
// eslint-disable-next-line no-await-in-loop
|
// eslint-disable-next-line no-await-in-loop
|
||||||
|
|||||||
@@ -243,6 +243,10 @@ export function getNode(domainId: string, _id: string) {
|
|||||||
return document.get(domainId, document.TYPE_DISCUSSION_NODE, _id);
|
return document.get(domainId, document.TYPE_DISCUSSION_NODE, _id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function flushNodes(domainId: string) {
|
||||||
|
return document.deleteMulti(domainId, document.TYPE_DISCUSSION_NODE);
|
||||||
|
}
|
||||||
|
|
||||||
export async function getVnode(domainId: string, type: number, id: string, uid?: number) {
|
export async function getVnode(domainId: string, type: number, id: string, uid?: number) {
|
||||||
if (type === document.TYPE_PROBLEM) {
|
if (type === document.TYPE_PROBLEM) {
|
||||||
const pdoc = await problem.get(domainId, Number.isSafeInteger(+id) ? +id : id);
|
const pdoc = await problem.get(domainId, Number.isSafeInteger(+id) ? +id : id);
|
||||||
@@ -360,6 +364,7 @@ global.Hydro.model.discussion = {
|
|||||||
setStatus,
|
setStatus,
|
||||||
addNode,
|
addNode,
|
||||||
getNode,
|
getNode,
|
||||||
|
flushNodes,
|
||||||
getNodes,
|
getNodes,
|
||||||
getVnode,
|
getVnode,
|
||||||
getListVnodes,
|
getListVnodes,
|
||||||
|
|||||||
Reference in new issue
Block a user