Moved showcase filter to computed column function.
This commit is contained in:
parent
156d1f2fbd
commit
c5201e37ee
|
@ -431,22 +431,9 @@ const releasesFragment = `
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
or: [
|
isShowcased: {
|
||||||
{
|
|
||||||
entity: {
|
|
||||||
showcased: {
|
|
||||||
equalTo: true
|
equalTo: true
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
{
|
|
||||||
studio: {
|
|
||||||
showcased: {
|
|
||||||
equalTo: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
first: $limit,
|
first: $limit,
|
||||||
offset: $offset,
|
offset: $offset,
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
exports.up = async (knex) => knex.raw(`
|
||||||
|
/* CREATE FUNCTION releases_is_showcased(release releases) RETURNS BOOLEAN AS $$
|
||||||
|
SELECT COALESCE(entities.showcased, false) OR COALESCE(studios.showcased, false) FROM releases
|
||||||
|
LEFT JOIN entities ON entities.id = releases.entity_id
|
||||||
|
LEFT JOIN entities AS studios ON studios.id = releases.studio_id
|
||||||
|
WHERE releases.id = release.id
|
||||||
|
$$ LANGUAGE SQL STABLE; */
|
||||||
|
|
||||||
|
CREATE FUNCTION releases_is_showcased(release releases) RETURNS BOOLEAN AS $$
|
||||||
|
SELECT COALESCE((SELECT showcased FROM entities WHERE entities.id = releases.entity_id), false)
|
||||||
|
OR COALESCE((SELECT showcased FROM entities WHERE entities.id = releases.studio_id), false) FROM releases
|
||||||
|
WHERE releases.id = release.id
|
||||||
|
$$ LANGUAGE SQL STABLE;
|
||||||
|
`);
|
||||||
|
|
||||||
|
exports.down = async (knex) => knex.raw(`
|
||||||
|
DROP FUNCTION IF EXISTS releases_is_showcased;
|
||||||
|
`);
|
Loading…
Reference in New Issue