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 <ek@stacker.news>
This commit is contained in:
Abhi Shandilya 2025-08-12 18:17:54 -04:00 committed by GitHub
parent 71ce403b0c
commit 6b01a41705
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 13 deletions

View File

@ -6,6 +6,7 @@ import { notifyTerritoryTransfer } from '@/lib/webPush'
import performPaidAction from '../paidAction' import performPaidAction from '../paidAction'
import { GqlAuthenticationError, GqlInputError } from '@/lib/error' import { GqlAuthenticationError, GqlInputError } from '@/lib/error'
import { uploadIdsFromText } from './upload' import { uploadIdsFromText } from './upload'
import { Prisma } from '@prisma/client'
export async function getSub (parent, { name }, { models, me }) { export async function getSub (parent, { name }, { models, me }) {
if (!name) return null if (!name) return null
@ -38,22 +39,13 @@ export default {
sub: getSub, sub: getSub,
subSuggestions: async (parent, { q, limit = 5 }, { models }) => { subSuggestions: async (parent, { q, limit = 5 }, { models }) => {
let subs = [] let subs = []
if (q) { subs = await models.$queryRaw`
subs = await models.$queryRaw`
SELECT name SELECT name
FROM "Sub" FROM "Sub"
WHERE status = 'ACTIVE' WHERE status IN ('ACTIVE', 'GRACE')
AND SIMILARITY(name, ${q}) > 0.1 ${q ? Prisma.sql`AND SIMILARITY(name, ${q}) > 0.1` : Prisma.empty}
ORDER BY SIMILARITY(name, ${q}) DESC ${q ? Prisma.sql`ORDER BY SIMILARITY(name, ${q}) DESC` : Prisma.sql`ORDER BY name ASC`}
LIMIT ${limit}` LIMIT ${limit}`
} else {
subs = await models.$queryRaw`
SELECT name
FROM "Sub"
WHERE status = 'ACTIVE'
ORDER BY name ASC
LIMIT ${limit}`
}
return subs return subs
}, },

View File

@ -15,3 +15,4 @@ Scroogey
SimpleStacker SimpleStacker
klk klk
brymut brymut
abhishandy