mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
bug fix
This commit is contained in:
1 parent
2b6a510c1e
commit
f2bcc3bc93
23 files changed
+241
-119
No files matched your search
@@ -245,7 +245,11 @@ async function edit(domainId, tid, $set, type = document.TYPE_CONTEST) {
|
||||
* @returns {Tdoc}
|
||||
*/
|
||||
async function get(domainId, tid, type = document.TYPE_CONTEST) {
|
||||
const tdoc = await document.get(domainId, type, tid);
|
||||
let tdoc;
|
||||
if (type === -1) {
|
||||
tdoc = await document.get(domainId, document.TYPE_CONTEST, tid);
|
||||
if (!tdoc) tdoc = await document.get(domainId, document.TYPE_HOMEWORK, tid);
|
||||
} else tdoc = await document.get(domainId, type, tid);
|
||||
if (!tdoc) throw new ContestNotFoundError(tid);
|
||||
return tdoc;
|
||||
}
|
||||
@@ -265,10 +269,11 @@ function getStatus(domainId, tid, uid, type = document.TYPE_CONTEST) {
|
||||
return document.getStatus(domainId, type, tid, uid);
|
||||
}
|
||||
|
||||
async function getListStatus(domainId, uid, tids) {
|
||||
async function getListStatus(domainId, uid, tids, type = document.TYPE_CONTEST) {
|
||||
const r = {};
|
||||
console.log(tids);
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
for (const tid of tids) r[tid] = await getStatus(domainId, tid, uid);
|
||||
for (const tid of tids) r[tid] = await getStatus(domainId, tid, uid, type);
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -327,7 +332,7 @@ const ContestHandlerMixin = (c) => class extends c {
|
||||
async getScoreboard(domainId, tid, isExport = false, docType = document.TYPE_CONTEST) {
|
||||
const tdoc = await get(domainId, tid, docType);
|
||||
if (!this.canShowScoreboard(tdoc)) throw new ContestScoreboardHiddenError(tid);
|
||||
const tsdocs = await getMultiStatus(domainId, tid, docType)
|
||||
const tsdocs = await getMultiStatus(domainId, { docId: tid }, docType)
|
||||
.sort(RULES[tdoc.rule].statusSort).toArray();
|
||||
const uids = [];
|
||||
for (const tsdoc of tsdocs) uids.push(tsdoc.uid);
|
||||
|
||||
+7
-23
@@ -5,29 +5,8 @@ const db = require('../service/db.js');
|
||||
const coll = db.collection('message');
|
||||
|
||||
async function send(from, to, content) {
|
||||
await coll.updateOne({
|
||||
from: Math.min(from, to),
|
||||
to: Math.max(from, to),
|
||||
}, {
|
||||
$push: {
|
||||
reply: {
|
||||
_id: new ObjectID(),
|
||||
from,
|
||||
content,
|
||||
unread: true,
|
||||
at: new Date(),
|
||||
},
|
||||
},
|
||||
$setOnInsert: {
|
||||
from: Math.min(from, to),
|
||||
to: Math.max(from, to),
|
||||
fromUnread: from > to,
|
||||
toUnread: from < to,
|
||||
},
|
||||
}, { upsert: true });
|
||||
return await coll.findOne({ // eslint-disable-line no-return-await
|
||||
from: Math.min(from, to),
|
||||
to: Math.max(from, to),
|
||||
await coll.insertOne({
|
||||
from, to, content, unread: true,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -37,6 +16,10 @@ async function get(_id) {
|
||||
return doc;
|
||||
}
|
||||
|
||||
function getByUser(uid) {
|
||||
return coll.find({ $or: [{ from: uid }, { to: uid }] }).toArray();
|
||||
}
|
||||
|
||||
function getMany(query, sort, page, limit) {
|
||||
return coll.find(query).sort(sort)
|
||||
.skip((page - 1) * limit).limit(limit)
|
||||
@@ -65,6 +48,7 @@ function ensureIndexes() {
|
||||
global.Hydro.model.message = module.exports = {
|
||||
count,
|
||||
get,
|
||||
getByUser,
|
||||
del,
|
||||
getMany,
|
||||
getMulti,
|
||||
|
||||
@@ -3,7 +3,6 @@ const db = require('../service/db');
|
||||
const coll = db.collection('task');
|
||||
|
||||
async function add(task) {
|
||||
console.log(task);
|
||||
const res = await coll.insertOne(task);
|
||||
return res.insertedId;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user