Skip to content

Commit

Permalink
Query to filter flagged proposals (#624)
Browse files Browse the repository at this point in the history
* Query to filter flagged proposals

* Update src/graphql/operations/proposals.ts

Co-authored-by: Less <[email protected]>

* Update src/graphql/operations/proposals.ts

Co-authored-by: Less <[email protected]>

---------

Co-authored-by: Less <[email protected]>
  • Loading branch information
ChaituVR and bonustrack authored Aug 1, 2023
1 parent 4c5609c commit cdc2c9f
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 cdc2c9f

Please sign in to comment.