🎈 perf(排行榜): 武将排行榜修改为读数据库

This commit is contained in:
luying
2023-05-06 20:24:16 +08:00
parent 95b3c0a880
commit d30abf287f
5 changed files with 120 additions and 36 deletions

View File

@@ -101,6 +101,8 @@ export class EPlace {
@index({ seqId: 1 })
@index({ roleId: 1, hid: 1 })
@index({ roleId: 1, ce: -1 })
@index({ serverId: 1, ce: -1 })
@index({ serverId: 1, hid: 1, ce: -1 })
export default class Hero extends BaseModel {
@prop({ required: true })
@@ -188,6 +190,16 @@ export default class Hero extends BaseModel {
return heroes
}
public static async findByServerIdAndSortByCe(serverId: number) {
const heroes: HeroType[] = await HeroROModel.find({ serverId }).sort({ ce: -1 }).select('hid skinId star colorStar lv quality job roleId ce').limit(200).lean();
return heroes
}
public static async findByServerIdAndHidAndSortByCe(serverId: number, hid: number) {
const heroes: HeroType[] = await HeroROModel.find({ serverId, hid }).sort({ ce: -1 }).select('hid skinId star colorStar lv quality job roleId ce').limit(200).lean();
return heroes
}
public static async findBySeqIdRange(seqIds: Array<number>, roleId: string, lean = true) {
const hero: HeroType[] = await HeroROModel.find({ seqId: { $in: seqIds }, roleId }).lean(lean);
return hero;