Skip to content

Commit

Permalink
Refactor unjudged command to use Prisma's SQL template for querying u…
Browse files Browse the repository at this point in the history
…njudged builds
  • Loading branch information
Mic-R committed Feb 10, 2025
1 parent 0a1f048 commit 40d0aef
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion commands/unjudged.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const { Prisma } = require("@prisma/client");

require("dotenv").config();

module.exports = {
Expand All @@ -7,7 +9,7 @@ module.exports = {
},
run: async (client, interaction, prisma) => {
//get all unjudged builds, that means judges[] cardinality is < 2
const unjudgedBuilds = await prisma.build.$queryRaw`SELECT id, \'https://discord.com/channels/${process.env.GUILD_ID}/${process.env.JUDGE_CHANNEL}/\' || judge_msg AS discord_url FROM objects WHERE cardinality(judges) < 2;`;
const unjudgedBuilds = await prisma.$queryRaw(Prisma.sql`SELECT id, \'https://discord.com/channels/${process.env.GUILD_ID}/${process.env.JUDGE_CHANNEL}/\' || judge_msg AS discord_url FROM objects WHERE cardinality(judges) < 2;`);

if (unjudgedBuilds.length === 0) {
return interaction.reply({
Expand Down

0 comments on commit 40d0aef

Please sign in to comment.