3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 20:35:02 +00:00

Add pagination to !cases -mod

This commit is contained in:
Dragory 2020-12-15 15:18:08 +02:00
parent 0c6ec9cef0
commit 5056b4376a
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
5 changed files with 87 additions and 31 deletions

View file

@ -82,7 +82,17 @@ export class GuildCases extends BaseGuildRepository {
});
}
async getRecentByModId(modId: string, count: number): Promise<Case[]> {
async getTotalCasesByModId(modId: string): Promise<number> {
return this.cases.count({
where: {
guild_id: this.guildId,
mod_id: modId,
is_hidden: 0,
},
});
}
async getRecentByModId(modId: string, count: number, skip = 0): Promise<Case[]> {
return this.cases.find({
relations: this.getRelations(),
where: {
@ -90,6 +100,7 @@ export class GuildCases extends BaseGuildRepository {
mod_id: modId,
is_hidden: 0,
},
skip,
take: count,
order: {
case_number: "DESC",