Added dedicated scene function and pagination to tag page.

This commit is contained in:
DebaucheryLibrarian 2020-09-09 04:22:43 +02:00
parent 6bb8d26561
commit d46ac6206d
7 changed files with 75 additions and 28 deletions

View File

@ -85,6 +85,8 @@ export default {
} }
.content-inner { .content-inner {
display: flex;
flex-direction: column;
flex-grow: 1; flex-grow: 1;
overflow-y: auto; overflow-y: auto;
overflow-x: hidden; overflow-x: hidden;

View File

@ -112,6 +112,7 @@ export default {
.pagination { .pagination {
display: flex; display: flex;
justify-content: center; justify-content: center;
flex-shrink: 0;
overflow: hidden; overflow: hidden;
height: 3rem; height: 3rem;
} }

View File

@ -84,6 +84,7 @@ export default {
} }
.releases { .releases {
flex-grow: 1;
border-top: solid 1px var(--crease); border-top: solid 1px var(--crease);
&.embedded { &.embedded {

View File

@ -30,7 +30,13 @@
</Scroll> </Scroll>
<FilterBar :fetch-releases="fetchReleases" /> <FilterBar :fetch-releases="fetchReleases" />
<Releases :releases="tag.releases" /> <Releases :releases="releases" />
<Pagination
:items-total="totalCount"
:items-per-page="limit"
class="pagination-bottom"
/>
<Footer /> <Footer />
</div> </div>
@ -46,16 +52,23 @@ import escapeHtml from '../../../src/utils/escape-html';
import FilterBar from '../filters/filter-bar.vue'; import FilterBar from '../filters/filter-bar.vue';
import Photos from './photos.vue'; import Photos from './photos.vue';
import Releases from '../releases/releases.vue'; import Releases from '../releases/releases.vue';
import Pagination from '../pagination/pagination.vue';
import Scroll from '../scroll/scroll.vue'; import Scroll from '../scroll/scroll.vue';
const converter = new Converter(); const converter = new Converter();
async function fetchReleases() { async function fetchReleases() {
this.tag = await this.$store.dispatch('fetchTagBySlug', { const { tag, releases, totalCount } = await this.$store.dispatch('fetchTagBySlug', {
tagSlug: this.$route.params.tagSlug, tagSlug: this.$route.params.tagSlug,
pageNumber: Number(this.$route.params.pageNumber),
limit: this.limit,
range: this.$route.params.range, range: this.$route.params.range,
}); });
this.tag = tag;
this.releases = releases;
this.totalCount = totalCount;
this.hasMedia = this.tag.poster || this.tag.photos.length > 0; this.hasMedia = this.tag.poster || this.tag.photos.length > 0;
this.description = this.tag.description && converter.makeHtml(escapeHtml(this.tag.description)); this.description = this.tag.description && converter.makeHtml(escapeHtml(this.tag.description));
} }
@ -74,6 +87,7 @@ export default {
FilterBar, FilterBar,
Releases, Releases,
Photos, Photos,
Pagination,
Scroll, Scroll,
}, },
data() { data() {
@ -81,6 +95,8 @@ export default {
tag: null, tag: null,
description: null, description: null,
releases: null, releases: null,
totalCount: 0,
limit: 15,
pageTitle: null, pageTitle: null,
hasMedia: false, hasMedia: false,
expanded: false, expanded: false,

View File

@ -125,11 +125,12 @@ const routes = [
params: { params: {
...from.params, ...from.params,
range: 'latest', range: 'latest',
pageNumber: 1,
}, },
}), }),
}, },
{ {
path: '/tag/:tagSlug/:range', path: '/tag/:tagSlug/:range/:pageNumber',
component: Tag, component: Tag,
name: 'tag', name: 'tag',
}, },

View File

@ -2,20 +2,26 @@ import { graphql, get } from '../api';
import { import {
releaseFields, releaseFields,
} from '../fragments'; } from '../fragments';
import { curateTag } from '../curate'; import { curateTag, curateRelease } from '../curate';
import getDateRange from '../get-date-range'; import getDateRange from '../get-date-range';
function initTagsActions(store, _router) { function initTagsActions(store, _router) {
async function fetchTagBySlug({ _commit }, { tagSlug, limit = 100, range = 'latest' }) { async function fetchTagBySlug({ _commit }, {
tagSlug,
pageNumber = 1,
limit = 100,
range = 'latest',
}) {
const { before, after, orderBy } = getDateRange(range); const { before, after, orderBy } = getDateRange(range);
const { tagBySlug } = await graphql(` const { tagBySlug } = await graphql(`
query Tag( query Tag(
$tagSlug:String! $tagSlug:String!
$offset: Int = 0,
$limit:Int = 1000, $limit:Int = 1000,
$after:Datetime = "1900-01-01", $after:Datetime = "1900-01-01",
$before:Datetime = "2100-01-01", $before:Datetime = "2100-01-01",
$orderBy: [ReleasesTagsOrderBy!], $orderBy: [ReleasesOrderBy!],
$exclude: [String!] $exclude: [String!]
) { ) {
tagBySlug(slug:$tagSlug) { tagBySlug(slug:$tagSlug) {
@ -57,31 +63,31 @@ function initTagsActions(store, _router) {
} }
} }
} }
releases: releasesTags( scenesConnection(
filter: { filter: {
release: { date: {
date: { lessThan: $before,
lessThan: $before, greaterThan: $after,
greaterThan: $after, },
}, releasesTagsConnection: {
releasesTagsConnection: { none: {
none: { tag: {
tag: { slug: {
slug: { in: $exclude
in: $exclude }
} }
} }
} }
}
}
}, },
first: $limit, first: $limit,
orderBy: $orderBy, orderBy: $orderBy,
offset: $offset
) { ) {
release { releases: nodes {
${releaseFields} ${releaseFields}
} }
} totalCount
}
} }
} }
`, { `, {
@ -89,11 +95,16 @@ function initTagsActions(store, _router) {
limit, limit,
after, after,
before, before,
orderBy: orderBy === 'DATE_DESC' ? 'RELEASE_BY_RELEASE_ID__DATE_DESC' : 'RELEASE_BY_RELEASE_ID__DATE_ASC', orderBy: orderBy === 'DATE_DESC' ? 'DATE_DESC' : 'DATE_ASC',
offset: Math.max(0, (pageNumber - 1)) * limit,
exclude: store.state.ui.filter, exclude: store.state.ui.filter,
}); });
return curateTag(tagBySlug, store); return {
tag: curateTag(tagBySlug, null, curateRelease),
releases: tagBySlug.scenesConnection.releases.map(release => curateRelease(release)),
totalCount: tagBySlug.scenesConnection.totalCount,
};
} }
async function fetchTags({ _commit }, { async function fetchTags({ _commit }, {

View File

@ -1031,6 +1031,19 @@ exports.up = knex => Promise.resolve()
END; END;
$$ LANGUAGE SQL STABLE; $$ LANGUAGE SQL STABLE;
CREATE FUNCTION tags_scenes(tag tags, selected_tags text[], mode text DEFAULT 'all') RETURNS SETOF releases AS $$
SELECT releases.*
FROM releases
LEFT JOIN
releases_actors ON releases_actors.release_id = releases.id
LEFT JOIN
releases_tags ON releases_tags.release_id = releases.id
LEFT JOIN
tags ON tags.id = releases_tags.tag_id
WHERE releases_tags.tag_id = tag.id
GROUP BY releases.id;
$$ LANGUAGE SQL STABLE;
CREATE FUNCTION movies_actors(movie movies) RETURNS SETOF actors AS $$ CREATE FUNCTION movies_actors(movie movies) RETURNS SETOF actors AS $$
SELECT actors.* SELECT actors.*
FROM movies_scenes FROM movies_scenes
@ -1090,6 +1103,8 @@ exports.up = knex => Promise.resolve()
COMMENT ON FUNCTION actors_tags IS E'@sortable'; COMMENT ON FUNCTION actors_tags IS E'@sortable';
COMMENT ON FUNCTION actors_channels IS E'@sortable'; COMMENT ON FUNCTION actors_channels IS E'@sortable';
COMMENT ON FUNCTION actors_scenes IS E'@sortable'; COMMENT ON FUNCTION actors_scenes IS E'@sortable';
COMMENT ON FUNCTION tags_scenes IS E'@sortable';
`); `);
}); });