Improve date range precision.

This commit is contained in:
DebaucheryLibrarian 2020-09-11 02:29:14 +02:00
parent aa74c1c721
commit 471f8f2bec
3 changed files with 26 additions and 14 deletions

View File

@ -5,23 +5,23 @@ dayjs.extend(utc);
const dateRanges = { const dateRanges = {
latest: () => ({ latest: () => ({
after: '1900-01-01 00:00:00', after: '1900-01-01',
before: dayjs.utc().format('YYYY-MM-DD HH:mm:ss'), before: dayjs.utc().toDate(),
orderBy: 'DATE_DESC', orderBy: 'DATE_DESC',
}), }),
upcoming: () => ({ upcoming: () => ({
after: dayjs.utc().format('YYYY-MM-DD HH:mm:ss'), after: dayjs.utc().toDate(),
before: '2100-01-01 00:00:00', before: '2100-01-01',
orderBy: 'DATE_ASC', orderBy: 'DATE_ASC',
}), }),
new: () => ({ new: () => ({
after: '1900-01-01 00:00:00', after: '1900-01-01 00:00:00',
before: '2100-01-01 00:00:00', before: '2100-01-01',
orderBy: ['CREATED_AT_DESC', 'DATE_ASC'], orderBy: ['CREATED_AT_DESC', 'DATE_ASC'],
}), }),
all: () => ({ all: () => ({
after: '1900-01-01 00:00:00', after: '1900-01-01',
before: '2100-01-01 00:00:00', before: '2100-01-01',
orderBy: 'DATE_DESC', orderBy: 'DATE_DESC',
}), }),
}; };

View File

@ -1004,6 +1004,8 @@ exports.up = knex => Promise.resolve()
GROUP BY entities.id; GROUP BY entities.id;
$$ LANGUAGE SQL STABLE; $$ 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 $$ CREATE FUNCTION actors_scenes(actor actors, selected_tags text[], mode text DEFAULT 'all') RETURNS SETOF releases AS $$
SELECT releases.* SELECT releases.*
FROM releases FROM releases
@ -1015,18 +1017,22 @@ exports.up = knex => Promise.resolve()
tags ON tags.id = releases_tags.tag_id tags ON tags.id = releases_tags.tag_id
WHERE releases_actors.actor_id = actor.id WHERE releases_actors.actor_id = actor.id
AND CASE 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) THEN tags.slug = ANY(selected_tags)
ELSE true ELSE true
END END
GROUP BY releases.id GROUP BY releases.id
HAVING CASE HAVING CASE
WHEN mode = 'all' AND array_length(selected_tags, 1) > 0 /* match all of the selected tags */
THEN COUNT( WHEN mode = 'all'
CASE WHEN tags.slug = ANY(selected_tags) AND array_length(selected_tags, 1) > 0
THEN true THEN COUNT(
END CASE WHEN tags.slug = ANY(selected_tags)
) = array_length(selected_tags, 1) THEN true
END
) = array_length(selected_tags, 1)
ELSE true ELSE true
END; END;
$$ LANGUAGE SQL STABLE; $$ LANGUAGE SQL STABLE;

View File

@ -110,6 +110,12 @@ const studios = [
url: 'https://www.legalporno.com/studios/omar-galanti-productions', url: 'https://www.legalporno.com/studios/omar-galanti-productions',
parent: 'legalporno', parent: 'legalporno',
}, },
{
slug: 'marywet',
name: 'Marywet',
url: 'https://www.legalporno.com/studios/marywet',
parent: 'legalporno',
},
{ {
slug: 'norestfortheass', slug: 'norestfortheass',
name: 'No Rest For The Ass', name: 'No Rest For The Ass',