Skip to content

Commit aa90b2c

Browse files
ilmartyrkDiverVM
andauthored
#1528 (#482)
* feature: Add docker files * #2302 fix (#475) * add demographics filter (#466) * update filtering * clean code --------- Co-authored-by: Victor <[email protected]> * add search --------- Co-authored-by: Victor <[email protected]>
1 parent b123996 commit aa90b2c

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed

Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Use official Node.js 20 image
2+
FROM node:20-alpine
3+
4+
# Set working directory
5+
WORKDIR /usr/src/app
6+
7+
# Install dependencies first for better caching
8+
COPY package.json npm-shrinkwrap.json ./
9+
RUN npm ci --omit=dev
10+
11+
# Copy the rest of the application
12+
COPY . .
13+
14+
# Expose the default port
15+
EXPOSE 3002
16+
EXPOSE 3003
17+
18+
# Start the app
19+
CMD ["node", "./bin/www"]

docker-compose.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
version: '3.8'
2+
3+
services:
4+
citizenos-api:
5+
build: .
6+
container_name: citizenos-api
7+
ports:
8+
- "3003:3003"
9+
environment:
10+
# Database connection string (adjust as needed)
11+
DATABASE_URL: postgres://citizenos:citizenos@db:5432/citizenos
12+
# Redis connection string
13+
REDIS_URL: redis://redis:6379
14+
# Add other environment variables as needed, for example:
15+
# CITIZENOS_URL_API: https://api.citizenos.com
16+
# CITIZENOS_URL_FE: https://app.citizenos.com
17+
# CITIZENOS_API_KEY: your_api_key_here
18+
depends_on:
19+
- db
20+
- redis
21+
22+
db:
23+
image: postgres:15
24+
container_name: citizenos-db
25+
environment:
26+
POSTGRES_USER: citizenos
27+
POSTGRES_PASSWORD: citizenos
28+
POSTGRES_DB: citizenos
29+
# ports:
30+
# - "5432:5432"
31+
volumes:
32+
- db_data:/var/lib/postgresql/data
33+
- ./db/config/database.sql:/docker-entrypoint-initdb.d/database.sql:ro
34+
35+
redis:
36+
image: redis:7
37+
container_name: citizenos-redis
38+
ports:
39+
- "6379:6379"
40+
volumes:
41+
- redis_data:/data
42+
43+
volumes:
44+
db_data:
45+
redis_data:

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)