forked from DebaucheryLibrarian/traxxx
Moved tag filter modes to postgres function.
This commit is contained in:
parent
cf999896d5
commit
70bf00e844
|
@ -18,7 +18,7 @@
|
||||||
<select
|
<select
|
||||||
v-model="mode"
|
v-model="mode"
|
||||||
class="mode"
|
class="mode"
|
||||||
@change="$router.push({ query: { ...$route.query, mode } })"
|
@change="$router.push({ query: { ...$route.query, mode }, params: { pageNumber: 1 } })"
|
||||||
>
|
>
|
||||||
<option
|
<option
|
||||||
value="all"
|
value="all"
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
class="tag"
|
class="tag"
|
||||||
:class="{ selected: selectedTags.includes(tag.slug) }"
|
:class="{ selected: selectedTags.includes(tag.slug) }"
|
||||||
>
|
>
|
||||||
<router-link :to="{ query: { ...getNewRange(tag.slug), mode } }">
|
<router-link :to="{ query: { ...getNewRange(tag.slug), mode }, params: { pageNumber: 1 } }">
|
||||||
<Icon
|
<Icon
|
||||||
icon="checkmark"
|
icon="checkmark"
|
||||||
class="include"
|
class="include"
|
||||||
|
@ -88,7 +88,7 @@ export default {
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
mode: 'all',
|
mode: this.$route.query.mode || 'all',
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
|
@ -25,6 +25,7 @@ function initActorActions(store, router) {
|
||||||
$orderBy:[ReleasesOrderBy!]
|
$orderBy:[ReleasesOrderBy!]
|
||||||
$selectableTags: [String],
|
$selectableTags: [String],
|
||||||
$includeTags: [String!],
|
$includeTags: [String!],
|
||||||
|
$mode: String!,
|
||||||
) {
|
) {
|
||||||
actor(id: $actorId) {
|
actor(id: $actorId) {
|
||||||
id
|
id
|
||||||
|
@ -151,19 +152,9 @@ function initActorActions(store, router) {
|
||||||
lessThan: $before,
|
lessThan: $before,
|
||||||
greaterThan: $after,
|
greaterThan: $after,
|
||||||
}
|
}
|
||||||
${mode === 'any' ? `
|
|
||||||
releasesTagsConnection: {
|
|
||||||
some: {
|
|
||||||
tag: {
|
|
||||||
slug: {
|
|
||||||
in: $includeTags
|
|
||||||
}
|
}
|
||||||
}
|
selectedTags: $includeTags
|
||||||
}
|
mode: $mode
|
||||||
}
|
|
||||||
` : ''}
|
|
||||||
}
|
|
||||||
${mode === 'all' ? 'selectedTags: $includeTags' : ''}
|
|
||||||
first: $limit
|
first: $limit
|
||||||
offset: $offset
|
offset: $offset
|
||||||
orderBy: $orderBy
|
orderBy: $orderBy
|
||||||
|
@ -185,6 +176,7 @@ function initActorActions(store, router) {
|
||||||
orderBy,
|
orderBy,
|
||||||
excludeTags: store.state.ui.filter,
|
excludeTags: store.state.ui.filter,
|
||||||
includeTags,
|
includeTags,
|
||||||
|
mode,
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -857,7 +857,7 @@ exports.up = knex => Promise.resolve()
|
||||||
ORDER BY tags.name;
|
ORDER BY tags.name;
|
||||||
$$ LANGUAGE SQL STABLE;
|
$$ LANGUAGE SQL STABLE;
|
||||||
|
|
||||||
CREATE FUNCTION actors_scenes(actor actors, selected_tags text[]) 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
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
|
@ -869,9 +869,14 @@ exports.up = knex => Promise.resolve()
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
tags ON tags.id = releases_tags.tag_id
|
tags ON tags.id = releases_tags.tag_id
|
||||||
WHERE actors.id = actor.id
|
WHERE actors.id = actor.id
|
||||||
|
AND CASE
|
||||||
|
WHEN mode = 'any' AND array_length(selected_tags, 1) > 0
|
||||||
|
THEN tags.slug = ANY(selected_tags)
|
||||||
|
ELSE true
|
||||||
|
END
|
||||||
GROUP BY releases.id
|
GROUP BY releases.id
|
||||||
HAVING CASE
|
HAVING CASE
|
||||||
WHEN array_length(selected_tags, 1) > 0
|
WHEN mode = 'all' AND array_length(selected_tags, 1) > 0
|
||||||
THEN COUNT(
|
THEN COUNT(
|
||||||
CASE WHEN tags.slug = ANY(selected_tags)
|
CASE WHEN tags.slug = ANY(selected_tags)
|
||||||
THEN true
|
THEN true
|
||||||
|
|
Loading…
Reference in New Issue