forked from DebaucheryLibrarian/traxxx
Improve date range precision.
This commit is contained in:
@@ -1004,6 +1004,8 @@ exports.up = knex => Promise.resolve()
|
||||
GROUP BY entities.id;
|
||||
$$ 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 */
|
||||
CREATE FUNCTION actors_scenes(actor actors, selected_tags text[], mode text DEFAULT 'all') RETURNS SETOF releases AS $$
|
||||
SELECT releases.*
|
||||
FROM releases
|
||||
@@ -1015,18 +1017,22 @@ exports.up = knex => Promise.resolve()
|
||||
tags ON tags.id = releases_tags.tag_id
|
||||
WHERE releases_actors.actor_id = actor.id
|
||||
AND CASE
|
||||
WHEN mode = 'any' AND array_length(selected_tags, 1) > 0
|
||||
/* match at least one of the selected tags */
|
||||
WHEN mode = 'any'
|
||||
AND array_length(selected_tags, 1) > 0
|
||||
THEN tags.slug = ANY(selected_tags)
|
||||
ELSE true
|
||||
END
|
||||
GROUP BY releases.id
|
||||
HAVING CASE
|
||||
WHEN mode = 'all' AND array_length(selected_tags, 1) > 0
|
||||
THEN COUNT(
|
||||
CASE WHEN tags.slug = ANY(selected_tags)
|
||||
THEN true
|
||||
END
|
||||
) = array_length(selected_tags, 1)
|
||||
/* match all of the selected tags */
|
||||
WHEN mode = 'all'
|
||||
AND array_length(selected_tags, 1) > 0
|
||||
THEN COUNT(
|
||||
CASE WHEN tags.slug = ANY(selected_tags)
|
||||
THEN true
|
||||
END
|
||||
) = array_length(selected_tags, 1)
|
||||
ELSE true
|
||||
END;
|
||||
$$ LANGUAGE SQL STABLE;
|
||||
|
||||
Reference in New Issue
Block a user