Skip to content

Commit

Permalink
feat: add filter to search proposals by labels (#948)
Browse files Browse the repository at this point in the history
* feat: add filter to search proposals by labels

* fix: ignore empty labels filters
  • Loading branch information
wa0x6e authored Oct 19, 2024
1 parent ccbb853 commit 5df8ed1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/graphql/operations/proposals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ export default async function (parent, args) {
searchSql += ' AND p.flagged = 0';
}

if (where?.labels_in?.length) {
searchSql += ' AND JSON_OVERLAPS(p.labels, ?)';
params.push(JSON.stringify(where.labels_in));
}

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 @@ -221,6 +221,7 @@ input ProposalWhere {
end_lte: Int
scores_state: String
scores_state_in: [String]
labels_in: [String]
state: String
space_verified: Boolean
flagged: Boolean
Expand Down

0 comments on commit 5df8ed1

Please sign in to comment.