Skip to content

Commit

Permalink
Query to filter flagged proposals
Browse files Browse the repository at this point in the history
  • Loading branch information
ChaituVR committed Jul 29, 2023
1 parent 4c5609c commit dd13b89
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/graphql/operations/proposals.ts
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -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';
Expand Down
1 change: 1 addition & 0 deletions src/graphql/schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ input ProposalWhere {
scores_state_in: [String]
state: String
space_verified: Boolean
flagged: Boolean
}

input VoteWhere {
Expand Down

0 comments on commit dd13b89

Please sign in to comment.