From afa0123d228ac678d73d7d23a9dbe1c9d2d5a59d Mon Sep 17 00:00:00 2001 From: Isaac Date: Wed, 24 May 2023 21:04:28 +0100 Subject: [PATCH] perf: select 10 rows in SQL rather than JS --- src/commands/slash/tickets.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/commands/slash/tickets.js b/src/commands/slash/tickets.js index 95a0d91..e39dd8c 100644 --- a/src/commands/slash/tickets.js +++ b/src/commands/slash/tickets.js @@ -73,6 +73,7 @@ module.exports = class TicketsSlashCommand extends SlashCommand { const closed = await client.prisma.ticket.findMany({ include: { category: true }, orderBy: { createdAt: 'desc' }, + take: 10, // max 10 rows where: { createdById: member.id, guildId: interaction.guild.id, @@ -102,7 +103,7 @@ module.exports = class TicketsSlashCommand extends SlashCommand { } else { fields.push({ 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)}\`` : ''; return `> ${ticket.category.name} #${ticket.number} ${topic}`; }).join('\n'), @@ -129,4 +130,4 @@ module.exports = class TicketsSlashCommand extends SlashCommand { return await interaction.editReply({ embeds: [embed] }); } -}; \ No newline at end of file +};