core: record: add index [domainId, pid]

This commit is contained in:
undefined committed 2024-06-26 00:00:10 +08:00
1 parent 7be29b19f6
commit 34f470d50f
7 files changed
+26 -25

No files matched your search

+7 -6
View File
@@ -280,22 +280,23 @@ export function apply(ctx: Context) {
}, { upsert: true });
}
});
ctx.on('ready', async () => {
await db.ensureIndexes(
ctx.on('ready', () => Promise.all([
db.ensureIndexes(
RecordModel.coll,
{ key: { domainId: 1, pid: 1 }, name: 'delete' },
{ key: { domainId: 1, contest: 1, _id: -1 }, name: 'basic' },
{ key: { domainId: 1, contest: 1, uid: 1, _id: -1 }, name: 'withUser' },
{ key: { domainId: 1, contest: 1, pid: 1, _id: -1 }, name: 'withProblem' },
{ key: { domainId: 1, contest: 1, pid: 1, uid: 1, _id: -1 }, name: 'withUserAndProblem' },
{ key: { domainId: 1, contest: 1, status: 1, _id: -1 }, name: 'withStatus' },
);
await db.ensureIndexes(
),
db.ensureIndexes(
RecordModel.collStat,
{ key: { domainId: 1, pid: 1, uid: 1, _id: -1 }, name: 'basic' },
{ key: { domainId: 1, pid: 1, uid: 1, time: 1 }, name: 'time' },
{ key: { domainId: 1, pid: 1, uid: 1, memory: 1 }, name: 'memory' },
{ key: { domainId: 1, pid: 1, uid: 1, length: 1 }, name: 'length' },
);
});
),
]) as any);
}
global.Hydro.model.record = RecordModel;