mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-11-17 17:23:08 +02:00
perf: select 10 rows in SQL rather than JS
This commit is contained in:
parent
22b15d7fd7
commit
afa0123d22
@ -73,6 +73,7 @@ module.exports = class TicketsSlashCommand extends SlashCommand {
|
|||||||
const closed = await client.prisma.ticket.findMany({
|
const closed = await client.prisma.ticket.findMany({
|
||||||
include: { category: true },
|
include: { category: true },
|
||||||
orderBy: { createdAt: 'desc' },
|
orderBy: { createdAt: 'desc' },
|
||||||
|
take: 10, // max 10 rows
|
||||||
where: {
|
where: {
|
||||||
createdById: member.id,
|
createdById: member.id,
|
||||||
guildId: interaction.guild.id,
|
guildId: interaction.guild.id,
|
||||||
@ -102,7 +103,7 @@ module.exports = class TicketsSlashCommand extends SlashCommand {
|
|||||||
} else {
|
} else {
|
||||||
fields.push({
|
fields.push({
|
||||||
name: getMessage('commands.slash.tickets.response.fields.closed.name'),
|
name: getMessage('commands.slash.tickets.response.fields.closed.name'),
|
||||||
value: closed.slice(0, 10).map(ticket => { // max 10 rows
|
value: closed.map(ticket => {
|
||||||
const topic = ticket.topic ? `- \`${decrypt(ticket.topic).replace(/\n/g, ' ').slice(0, 30)}\`` : '';
|
const topic = ticket.topic ? `- \`${decrypt(ticket.topic).replace(/\n/g, ' ').slice(0, 30)}\`` : '';
|
||||||
return `> ${ticket.category.name} #${ticket.number} ${topic}`;
|
return `> ${ticket.category.name} #${ticket.number} ${topic}`;
|
||||||
}).join('\n'),
|
}).join('\n'),
|
||||||
|
Loading…
Reference in New Issue
Block a user