Selecting parent and grantparent networks in entity releases filter.

This commit is contained in:
DebaucheryLibrarian 2023-06-19 01:25:31 +02:00
parent 4e6b098448
commit 67c1bc6b1c
2 changed files with 39 additions and 25 deletions

View File

@ -90,14 +90,28 @@ function initEntitiesActions(store, router) {
offset: $offset
orderBy: $orderBy
filter: {
entity: {
slug: {
equalTo: $entitySlug
}
type: {
equalTo: $entityType
}
}
entity: {
or: [
{
slug: { equalTo: $entitySlug }
type: { equalTo: $entityType }
}
{
parent:{
slug: { equalTo: $entitySlug }
type: { equalTo: $entityType }
}
}
{
parent:{
parent: {
slug: { equalTo: $entitySlug }
type: { equalTo: $entityType }
}
}
}
]
}
effectiveDate: {
lessThan: $before,
greaterThan: $after

View File

@ -1738,23 +1738,23 @@ exports.up = (knex) => Promise.resolve()
WHERE releases.entity_id = entity.id;
$$ LANGUAGE SQL STABLE;
CREATE FUNCTION entities_scene_tags(entity entities, selectable_tags text[]) RETURNS SETOF tags AS $$
SELECT tags.*
FROM releases
LEFT JOIN
releases_tags ON releases_tags.release_id = releases.id
LEFT JOIN
tags ON tags.id = releases_tags.tag_id
WHERE
releases.entity_id = entity.id
AND
CASE WHEN array_length(selectable_tags, 1) IS NOT NULL
THEN tags.slug = ANY(selectable_tags)
ELSE true
END
GROUP BY tags.id
ORDER BY tags.name;
$$ LANGUAGE SQL STABLE;
CREATE FUNCTION entities_scene_tags(entity entities, selectable_tags text[]) RETURNS SETOF tags AS $$
SELECT tags.*
FROM releases
LEFT JOIN
releases_tags ON releases_tags.release_id = releases.id
LEFT JOIN
tags ON tags.id = releases_tags.tag_id
WHERE
releases.entity_id = entity.id
AND
CASE WHEN array_length(selectable_tags, 1) IS NOT NULL
THEN tags.slug = ANY(selectable_tags)
ELSE true
END
GROUP BY tags.id
ORDER BY tags.name;
$$ LANGUAGE SQL STABLE;
/* GraphQL/Postgraphile 'every' applies to the data, will only include scenes for which every assigned tag is selected,
instead of what we want; scenes with every selected tag, but possibly also some others */