mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 09:38:19 +08:00
自动释放锁,优化record.getList()
This commit is contained in:
1 parent
d3deeaeb96
commit
2bf6adbaa0
12 files changed
+51
-28
No files matched your search
@@ -73,7 +73,7 @@ class ContestDetailHandler extends ContestHandler {
|
||||
if (this.canShowRecord(tdoc)) {
|
||||
const q = [];
|
||||
for (const i in psdict) q.push(psdict[i].rid);
|
||||
rdict = await record.getList(domainId, q);
|
||||
rdict = await record.getList(domainId, q, true);
|
||||
} else {
|
||||
for (const i in psdict) rdict[psdict[i].rid] = { _id: psdict[i].rid };
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import { ObjectID } from 'mongodb';
|
||||
import { isSafeInteger } from 'lodash';
|
||||
import { DiscussionNotFoundError, DocumentNotFoundError } from '../error';
|
||||
import { Drdoc, Mdoc } from '../interface';
|
||||
import paginate from '../lib/paginate';
|
||||
import * as system from '../model/system';
|
||||
import * as user from '../model/user';
|
||||
import * as message from '../model/message';
|
||||
import * as discussion from '../model/discussion';
|
||||
import * as document from '../model/document';
|
||||
import { PERM, PRIV } from '../model/builtin';
|
||||
@@ -213,6 +215,16 @@ class DiscussionDetailHandler extends DiscussionHandler {
|
||||
async postReply(domainId: string, did: ObjectID, content: string) {
|
||||
this.checkPerm(PERM.PERM_REPLY_DISCUSSION);
|
||||
this.limitRate('add_discussion', 3600, 30);
|
||||
// Notify related users
|
||||
const replies: Drdoc[] = await discussion.getMultiReply(domainId, did).toArray();
|
||||
const uids = Array.from(new Set(replies.map((drdoc) => drdoc.owner)));
|
||||
const tasks = uids.map((uid) => {
|
||||
if (uid !== this.user._id) {
|
||||
return message.send(1, uid, `Discussion update: ${domainId} ${did}`);
|
||||
}
|
||||
return Promise.resolve(null as Mdoc);
|
||||
});
|
||||
await Promise.all(tasks);
|
||||
await discussion.addReply(domainId, did, this.user._id, content, this.request.ip);
|
||||
this.back();
|
||||
}
|
||||
|
||||
@@ -24,11 +24,7 @@ import {
|
||||
Route, Connection, Handler, ConnectionHandler, Types, param, multipart,
|
||||
} from '../service/server';
|
||||
|
||||
const parseCategory = (value: string) => {
|
||||
if (!value) return [];
|
||||
console.log(value);
|
||||
return flatten(value.split('+').map((e) => e.split(','))).map((e) => e.trim());
|
||||
};
|
||||
const parseCategory = (value: string) => flatten(value.split('+').map((e) => e.split(','))).map((e) => e.trim());
|
||||
const parsePid = (value: string) => (isSafeInteger(value) ? parseInt(value, 10) : value);
|
||||
|
||||
class ProblemHandler extends Handler {
|
||||
|
||||
Reference in new issue
Block a user