Added indeces on releases entity_id and studio_id, restored showcase query.
This commit is contained in:
parent
67f5ea9de8
commit
f62a64c021
|
@ -431,9 +431,22 @@ const releasesFragment = `
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isShowcased: {
|
or: [
|
||||||
equalTo: true
|
{
|
||||||
}
|
entity: {
|
||||||
|
showcased: {
|
||||||
|
equalTo: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
studio: {
|
||||||
|
showcased: {
|
||||||
|
equalTo: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
first: $limit,
|
first: $limit,
|
||||||
offset: $offset,
|
offset: $offset,
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
/*
|
||||||
exports.up = async (knex) => knex.raw(`
|
exports.up = async (knex) => knex.raw(`
|
||||||
CREATE FUNCTION releases_is_showcased(release releases) RETURNS BOOLEAN AS $$
|
CREATE FUNCTION releases_is_showcased(release releases) RETURNS BOOLEAN AS $$
|
||||||
SELECT COALESCE(entities.showcased, false) OR COALESCE(studios.showcased, false) FROM releases
|
SELECT COALESCE(entities.showcased, false) OR COALESCE(studios.showcased, false) FROM releases
|
||||||
|
@ -5,14 +6,19 @@ exports.up = async (knex) => knex.raw(`
|
||||||
LEFT JOIN entities AS studios ON studios.id = releases.studio_id
|
LEFT JOIN entities AS studios ON studios.id = releases.studio_id
|
||||||
WHERE releases.id = release.id
|
WHERE releases.id = release.id
|
||||||
$$ LANGUAGE SQL STABLE;
|
$$ 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(`
|
exports.down = async (knex) => knex.raw(`
|
||||||
DROP FUNCTION IF EXISTS releases_is_showcased;
|
DROP FUNCTION IF EXISTS releases_is_showcased;
|
||||||
`);
|
`);
|
||||||
|
*/
|
||||||
|
|
||||||
|
exports.up = async (knex) => knex.schema.alterTable('releases', (table) => {
|
||||||
|
table.index('entity_id');
|
||||||
|
table.index('studio_id');
|
||||||
|
});
|
||||||
|
|
||||||
|
exports.down = async (knex) => knex.schema.alterTable('releases', (table) => {
|
||||||
|
table.dropIndex('entity_id');
|
||||||
|
table.dropIndex('studio_id');
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in New Issue