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:
parent
71ce403b0c
commit
6b01a41705
@ -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
|
||||||
},
|
},
|
||||||
|
@ -15,3 +15,4 @@ Scroogey
|
|||||||
SimpleStacker
|
SimpleStacker
|
||||||
klk
|
klk
|
||||||
brymut
|
brymut
|
||||||
|
abhishandy
|
Loading…
x
Reference in New Issue
Block a user