Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catalog Create Event Form Backend Updates #60

Merged
merged 6 commits into from
Mar 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
);
Loading