Skip to content

Commit

Permalink
Catalog Create Event Form Backend Updates (#60)
Browse files Browse the repository at this point in the history
* Create a pull trequest for branch 57-catalog-create-event-form-backend

* accommodating for the multi select fields in the catalog form

* updated get request filters

* update catalog scheme + removed location from post req

* edited catalog put request

---------

Co-authored-by: Lana Ramadan <[email protected]>
Co-authored-by: michellelin1 <[email protected]>
  • Loading branch information
3 people authored Mar 24, 2024
1 parent b5327bf commit fc9ecfa
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', 'winter');
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 fc9ecfa

Please sign in to comment.