Skip to content

Commit e8b8914

Browse files
ilmartyrkDiverVM
andauthored
add search (#481)
Co-authored-by: Viktar Maslouski <[email protected]>
1 parent 374de54 commit e8b8914

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

routes/api/ideation.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,7 @@ module.exports = function (app) {
979979

980980
const _readIdeationIdeas = async (req, res, next) => {
981981
const ideationId = req.params.ideationId;
982+
const search = req.query.search;
982983
const limit = req.query.limit || 8;
983984
const offset = req.query.offset || 0;
984985
const orderBy = req.query.orderBy;
@@ -1017,6 +1018,12 @@ module.exports = function (app) {
10171018
if (authorId) {
10181019
where += ` AND "Idea"."authorId" = :authorId `;
10191020
}
1021+
if (search) {
1022+
where += ` AND (
1023+
"Idea"."statement" ILIKE '%' || :search || '%' OR
1024+
"Idea"."description" ILIKE '%' || :search || '%'
1025+
) `;
1026+
}
10201027
if (status) {
10211028
if (status === 'draft') {
10221029
where += ` AND "Idea"."status" = :status `;
@@ -1169,6 +1176,7 @@ module.exports = function (app) {
11691176
;
11701177
`, {
11711178
replacements: {
1179+
search,
11721180
userId: req.user?.id || req.user?.userId,
11731181
ideationId,
11741182
authorId,

0 commit comments

Comments
 (0)