Skip to content

Commit

Permalink
Merge branch 'dev' into day-planner-flow
Browse files Browse the repository at this point in the history
  • Loading branch information
michellelin1 committed Mar 28, 2024
2 parents da2e354 + fc9ecfa commit 2c13a25
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
16 changes: 4 additions & 12 deletions routes/catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,39 +29,31 @@ catalogRouter.get('/', async (req, res) => {

if (subject) {
const array = subject.split(',');
query += ' AND subject = ANY($2::subject[])';
// for (let i = 0; i < array.length; i += 1) {
// query += `'${array[i]}'`;
// if (i < array.length - 1) {
// query += ', ';
// }
// }
// query += ')';
// query += ' AND subject = $2';
query += ' AND subject && $2::subject[]';
params.push(array);
} else {
params.push('');
}

if (eventType) {
const array = eventType.split(',');
query += ' AND event_type = ANY($3::event[])';
query += ' AND event_type && $3::event[]';
params.push(array);
} else {
params.push('');
}

if (season) {
const array = season.split(',');
query += ' AND season = ANY($4::season[])';
query += ' AND season && $4::season[]';
params.push(array);
} else {
params.push('');
}

if (year) {
const array = year.split(',');
query += ' AND year = ANY($5::year[])';
query += ' AND year && $5::year[]';
params.push(array);
} else {
params.push('');
Expand Down
14 changes: 7 additions & 7 deletions server/schema/catalog.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ CREATE TYPE season AS ENUM ('spring', 'summer', 'fall');
DROP TABLE IF EXISTS catalog;
CREATE TABLE catalog (
id SERIAL PRIMARY KEY,
host VARCHAR(50) NOT NULL,
host VARCHAR(50),
title VARCHAR(50) NOT NULL,
event_type event[] NOT NULL,
subject subject[] NOT NULL,
description VARCHAR(50) NOT NULL,
year year NOT NULL,
season season,
hidden boolean NOT NULL
event_type event[] NOT NULL DEFAULT '{}',
subject subject[] NOT NULL DEFAULT '{}',
description VARCHAR(256),
year year[] NOT NULL DEFAULT '{}',
season season[] NOT NULL DEFAULT '{}',
hidden BOOLEAN NOT NULL,
);

0 comments on commit 2c13a25

Please sign in to comment.