From 6b01a417050211ce32d18cf5ba1b977861a67ca5 Mon Sep 17 00:00:00 2001 From: Abhi Shandilya Date: Tue, 12 Aug 2025 18:17:54 -0400 Subject: [PATCH] fix: include subs in grace status in suggestions (#2405) * include subs in grace status in suggestions * make myself a contributor * Refactor subSuggestions with Prisma.sql --------- Co-authored-by: ekzyis --- api/resolvers/sub.js | 18 +++++------------- contributors.txt | 1 + 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/api/resolvers/sub.js b/api/resolvers/sub.js index 15a7369a..25aede5a 100644 --- a/api/resolvers/sub.js +++ b/api/resolvers/sub.js @@ -6,6 +6,7 @@ import { notifyTerritoryTransfer } from '@/lib/webPush' import performPaidAction from '../paidAction' import { GqlAuthenticationError, GqlInputError } from '@/lib/error' import { uploadIdsFromText } from './upload' +import { Prisma } from '@prisma/client' export async function getSub (parent, { name }, { models, me }) { if (!name) return null @@ -38,22 +39,13 @@ export default { sub: getSub, subSuggestions: async (parent, { q, limit = 5 }, { models }) => { let subs = [] - if (q) { - subs = await models.$queryRaw` + subs = await models.$queryRaw` SELECT name FROM "Sub" - WHERE status = 'ACTIVE' - AND SIMILARITY(name, ${q}) > 0.1 - ORDER BY SIMILARITY(name, ${q}) DESC + WHERE status IN ('ACTIVE', 'GRACE') + ${q ? Prisma.sql`AND SIMILARITY(name, ${q}) > 0.1` : Prisma.empty} + ${q ? Prisma.sql`ORDER BY SIMILARITY(name, ${q}) DESC` : Prisma.sql`ORDER BY name ASC`} LIMIT ${limit}` - } else { - subs = await models.$queryRaw` - SELECT name - FROM "Sub" - WHERE status = 'ACTIVE' - ORDER BY name ASC - LIMIT ${limit}` - } return subs }, diff --git a/contributors.txt b/contributors.txt index 8c623f7e..32d49fee 100644 --- a/contributors.txt +++ b/contributors.txt @@ -15,3 +15,4 @@ Scroogey SimpleStacker klk brymut +abhishandy \ No newline at end of file