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

41 catalog match high fidelity (backend) #56

Merged
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
31 changes: 22 additions & 9 deletions routes/catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ catalogRouter.get('/', async (req, res) => {

const offset = (page - 1) * limit;

let query = ' FROM catalog WHERE 1=1';
let query = 'FROM catalog WHERE 1=1';
// removed space at beginning here

const params = [];

Expand All @@ -27,29 +28,41 @@ catalogRouter.get('/', async (req, res) => {
}

if (subject) {
query += ' AND subject = $2';
params.push(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';
params.push(array);
} else {
params.push('');
}

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

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

if (year) {
query += ' AND year = $5';
params.push(year);
const array = year.split(',');
query += ' AND year = ANY($5::year[])';
params.push(array);
} else {
params.push('');
}
Expand Down
Loading