core: remove undocumented domain.union feature

This commit is contained in:
undefined committed 2022-10-03 14:27:59 +08:00
1 parent f93108f160
commit efb8adfe6d
7 files changed
+12 -36

No files matched your search

+1 -1
View File
@@ -298,7 +298,7 @@ class UserDetailHandler extends Handler {
const [udoc, sdoc, union] = await Promise.all([
user.getById(domainId, uid),
token.getMostRecentSessionByUid(uid, ['createAt', 'updateAt']),
domain.getUnion(domainId),
domain.get(domainId),
]);
if (!udoc) throw new UserNotFoundError(uid);
const pdocs: ProblemDoc[] = [];
-7
View File
@@ -385,12 +385,6 @@ export interface DomainDoc extends Record<string, any> {
host?: string[],
}
export interface DomainUnion {
_id: string;
union: string[];
problem: boolean;
}
// Message
export interface MessageDoc {
_id: ObjectID,
@@ -604,7 +598,6 @@ export interface Collections {
'blacklist': BlacklistDoc;
'domain': DomainDoc;
'domain.user': any;
'domain.union': DomainUnion;
'record': RecordDoc;
'document': any;
'document.status': StatusDocBase;
+2 -17
View File
@@ -10,7 +10,6 @@ import UserModel, { deleteUserCache } from './user';
const coll = db.collection('domain');
const collUser = db.collection('domain.user');
const collUnion = db.collection('domain.union');
interface DomainUserArg {
_id: number,
@@ -254,23 +253,9 @@ class DomainModel {
}
@ArgMethod
static async addUnion(domainId: string, union: string[]) {
return await collUnion.updateOne({ _id: domainId }, { $set: { union } }, { upsert: true });
}
@ArgMethod
static async removeUnion(domainId: string) {
return await collUnion.deleteOne({ _id: domainId });
}
@ArgMethod
/** @deprecated */
static async getUnion(domainId: string) {
return await collUnion.findOne({ _id: domainId });
}
@ArgMethod
static async searchUnion(query) {
return await collUnion.find(query).toArray();
return await coll.findOne({ _id: domainId });
}
}
+2 -3
View File
@@ -152,9 +152,8 @@ export class ProblemModel {
page: number, pageSize: number,
projection = ProblemModel.PROJECTION_LIST, uid?: number,
): Promise<[ProblemDoc[], number, number]> {
const union = await DomainModel.getUnion(domainId);
const domainIds = [domainId];
if (union?.problem) domainIds.push(...union.union);
const union = await DomainModel.get(domainId);
const domainIds = [domainId, ...(union.union || [])];
let count = 0;
const pdocs = [];
for (const id of domainIds) {
+2 -3
View File
@@ -137,9 +137,8 @@ export async function calcLevel(domainId: string, report: Function) {
}
async function runInDomain(id: string, report: Function) {
const info = await domain.getUnion(id);
if (info) info.union.unshift(id);
const domainIds = info ? info.union : [id];
const info = await domain.get(id);
const domainIds = [id, ...(info.union || [])];
const results: Record<keyof typeof RpTypes, ND> = {};
const udict = new Proxy({}, { get: (self, key) => self[key] || 0 });
for (const type in RpTypes) {