Skip to content

Commit

Permalink
perf: select 10 rows in SQL rather than JS
Browse files Browse the repository at this point in the history
  • Loading branch information
eartharoid committed May 24, 2023
1 parent 22b15d7 commit afa0123
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/commands/slash/tickets.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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'),
Expand All @@ -129,4 +130,4 @@ module.exports = class TicketsSlashCommand extends SlashCommand {

return await interaction.editReply({ embeds: [embed] });
}
};
};

0 comments on commit afa0123

Please sign in to comment.