From dd13b89000fd9d987ced50f4f3a3f72cbcd73929 Mon Sep 17 00:00:00 2001 From: ChaituVR Date: Sun, 30 Jul 2023 00:35:01 +0530 Subject: [PATCH 1/3] Query to filter flagged proposals --- src/graphql/operations/proposals.ts | 12 +++++++++++- src/graphql/schema.gql | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/graphql/operations/proposals.ts b/src/graphql/operations/proposals.ts index eee59b11..e6107893 100644 --- a/src/graphql/operations/proposals.ts +++ b/src/graphql/operations/proposals.ts @@ -1,7 +1,7 @@ import db from '../../helpers/mysql'; import { buildWhereQuery, formatProposal, checkLimits } from '../helpers'; import log from '../../helpers/log'; -import { verifiedSpaces } from '../../helpers/moderation'; +import { flaggedProposals, verifiedSpaces } from '../../helpers/moderation'; import { capture } from '@snapshot-labs/snapshot-sentry'; export default async function (parent, args) { @@ -65,6 +65,16 @@ export default async function (parent, args) { params.push(verifiedSpaces); } + if (where.flagged === true) { + searchSql += ' AND p.id in (?)'; + params.push(flaggedProposals); + } + + if (where.flagged === false) { + searchSql += ' AND p.id not in (?)'; + params.push(flaggedProposals); + } + let orderBy = args.orderBy || 'created'; let orderDirection = args.orderDirection || 'desc'; if (!['created', 'start', 'end'].includes(orderBy)) orderBy = 'created'; diff --git a/src/graphql/schema.gql b/src/graphql/schema.gql index e1c2ba62..e2d954f9 100644 --- a/src/graphql/schema.gql +++ b/src/graphql/schema.gql @@ -200,6 +200,7 @@ input ProposalWhere { scores_state_in: [String] state: String space_verified: Boolean + flagged: Boolean } input VoteWhere { From abeb6f7f57605b305d2d9229292e509bcab156ad Mon Sep 17 00:00:00 2001 From: Chaitanya Date: Sun, 30 Jul 2023 00:55:55 +0530 Subject: [PATCH 2/3] Update src/graphql/operations/proposals.ts Co-authored-by: Less --- src/graphql/operations/proposals.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/graphql/operations/proposals.ts b/src/graphql/operations/proposals.ts index e6107893..de996da1 100644 --- a/src/graphql/operations/proposals.ts +++ b/src/graphql/operations/proposals.ts @@ -66,7 +66,7 @@ export default async function (parent, args) { } if (where.flagged === true) { - searchSql += ' AND p.id in (?)'; + searchSql += ' AND p.id IN (?)'; params.push(flaggedProposals); } From 6d4ede393aa10fd2a39d6a95c0c5bac1cd3e5b25 Mon Sep 17 00:00:00 2001 From: Chaitanya Date: Sun, 30 Jul 2023 00:56:00 +0530 Subject: [PATCH 3/3] Update src/graphql/operations/proposals.ts Co-authored-by: Less --- src/graphql/operations/proposals.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/graphql/operations/proposals.ts b/src/graphql/operations/proposals.ts index de996da1..b9c9e5f1 100644 --- a/src/graphql/operations/proposals.ts +++ b/src/graphql/operations/proposals.ts @@ -71,7 +71,7 @@ export default async function (parent, args) { } if (where.flagged === false) { - searchSql += ' AND p.id not in (?)'; + searchSql += ' AND p.id NOT IN (?)'; params.push(flaggedProposals); }