From 60c7e2a876a1f492f836a783cff1a537579a7e33 Mon Sep 17 00:00:00 2001 From: DebaucheryLibrarian Date: Tue, 3 Sep 2024 05:56:14 +0200 Subject: [PATCH] Added studios to filters and scene page. --- assets/css/theme.css | 3 +- components/filters/channels.vue | 4 +-- components/scenes/scenes.vue | 9 +++-- components/scenes/tile.vue | 16 +++++++++ pages/entities/@entitySlug/+Page.vue | 26 +++++++++++++- pages/entities/@entitySlug/+onBeforeRender.js | 4 ++- pages/entities/@entitySlug/+route.js | 2 +- pages/scene/+Page.vue | 12 +++++++ src/entities-prefixes.js | 6 ++++ src/entities.js | 8 +---- src/scenes.js | 35 +++++++++++++++++-- static | 2 +- 12 files changed, 108 insertions(+), 19 deletions(-) create mode 100644 src/entities-prefixes.js diff --git a/assets/css/theme.css b/assets/css/theme.css index 96d48ce..22aa4c1 100644 --- a/assets/css/theme.css +++ b/assets/css/theme.css @@ -63,7 +63,8 @@ --text: #222; --text-light: #fff; - --link: #48f; + /* --link: #48f; */ + --link: var(--primary); --male: #0af; --female: #f0a; diff --git a/components/filters/channels.vue b/components/filters/channels.vue index 418ae85..bf3d8a0 100644 --- a/components/filters/channels.vue +++ b/components/filters/channels.vue @@ -131,14 +131,14 @@ const entities = computed(() => { return acc; } - if (channel.parent && !acc[channel.parent.id] && channel.type === 'channel') { + if (!acc[channel.id] && channel.parent && !acc[channel.parent.id] && (channel.type === 'channel' || channel.type === 'studio')) { acc[channel.parent.id] = { ...channel.parent, children: [], }; } - if (channel.parent && channel.type === 'channel') { + if (!acc[channel.id] && channel.parent && (channel.type === 'channel' || channel.type === 'studio')) { acc[channel.parent.id].children.push(channel); } diff --git a/components/scenes/scenes.vue b/components/scenes/scenes.vue index e18cad7..3f94181 100644 --- a/components/scenes/scenes.vue +++ b/components/scenes/scenes.vue @@ -160,6 +160,7 @@ import { parse } from 'path-to-regexp'; import navigate from '#/src/navigate.js'; import { get } from '#/src/api.js'; import events from '#/src/events.js'; +import entityPrefixes from '#/src/entities-prefixes.js'; import { getActorIdentifier, parseActorIdentifier } from '#/src/query.js'; import Filters from '#/components/filters/filters.vue'; @@ -211,6 +212,8 @@ const aggActors = ref(pageProps.aggActors || []); const aggTags = ref(pageProps.aggTags || []); const aggChannels = ref(pageProps.aggChannels || []); +console.log(aggChannels.value); + const currentPage = ref(Number(routeParams.page)); const scope = ref(routeParams.scope || props.defaultScope); const total = ref(Number(pageProps.sceneTotal || pageProps.total)); @@ -277,7 +280,8 @@ async function search(options = {}) { }; const entity = filters.value.entity || pageEntity; - const entitySlug = entity?.type === 'network' ? `_${entity.slug}` : entity?.slug; + // const entitySlug = entity?.type === 'network' ? `_${entity.slug}` : entity?.slug; + const entitySlug = `${entityPrefixes[entity.type]}${entity.slug}`; loading.value = true; @@ -286,7 +290,8 @@ async function search(options = {}) { years: filters.value.years.join(',') || undefined, actors: filters.value.actors.map((filterActor) => getActorIdentifier(filterActor)).join(',') || undefined, // don't include page actor ID in query, already a parameter tags: filters.value.tags.join(',') || undefined, - e: filters.value.entity?.type === 'network' ? `_${filters.value.entity.slug}` : (filters.value.entity?.slug || undefined), + // e: filters.value.entity?.type === 'network' ? `_${filters.value.entity.slug}` : (filters.value.entity?.slug || undefined), + e: filters.value.entity ? `${entityPrefixes[filters.value.entity.type]}${filters.value.entity.slug}` : undefined, }, { redirect: false }); const res = await get('/scenes', { diff --git a/components/scenes/tile.vue b/components/scenes/tile.vue index 5772369..4b5936e 100644 --- a/components/scenes/tile.vue +++ b/components/scenes/tile.vue @@ -109,6 +109,16 @@ class="row tags nolist" :title="scene.tags.map((tag) => tag.name).join(', ')" > +
  • + {{ scene.shootId }} +
  • +
  • sceneStash.id === color: var(--glass-strong-10); font-size: .75rem; } + +.shoot { + color: var(--primary); + font-size: .75rem; + font-weight: bold; +} diff --git a/pages/entities/@entitySlug/+Page.vue b/pages/entities/@entitySlug/+Page.vue index 6f53b64..6ddc6cc 100644 --- a/pages/entities/@entitySlug/+Page.vue +++ b/pages/entities/@entitySlug/+Page.vue @@ -76,6 +76,19 @@ />
    +
    + +
    +
      { align-items: center; padding: .5rem; border: none; - background: var(--grey-dark-50); + background: var(--grey-dark-40); color: var(--highlight-strong-30); font-size: .9rem; font-weight: bold; @@ -274,6 +287,17 @@ const entityUrl = (() => { } } +.expand-top { + height: 0; + top: 3.5rem; + bottom: auto; + position: sticky; + + .expand { + height: 2rem; + } +} + .domains-bar { display: none; } diff --git a/pages/entities/@entitySlug/+onBeforeRender.js b/pages/entities/@entitySlug/+onBeforeRender.js index f6e04bf..8065e32 100644 --- a/pages/entities/@entitySlug/+onBeforeRender.js +++ b/pages/entities/@entitySlug/+onBeforeRender.js @@ -1,6 +1,7 @@ import { render } from 'vike/abort'; /* eslint-disable-line import/extensions */ import { fetchEntitiesById } from '#/src/entities.js'; +import entityPrefixes from '#/src/entities-prefixes.js'; import { fetchScenes } from '#/src/scenes.js'; import { fetchMovies } from '#/src/movies.js'; import { curateScenesQuery } from '#/src/web/scenes.js'; @@ -35,7 +36,8 @@ async function fetchReleases(pageContext, entityId) { } export async function onBeforeRender(pageContext) { - const entityId = await redis.hGet('traxxx:entities:id_by_slug', pageContext.routeParams.entityType === 'network' ? `_${pageContext.routeParams.entitySlug}` : pageContext.routeParams.entitySlug); + // const entityId = await redis.hGet('traxxx:entities:id_by_slug', pageContext.routeParams.entityType === 'network' ? `_${pageContext.routeParams.entitySlug}` : pageContext.routeParams.entitySlug); + const entityId = await redis.hGet('traxxx:entities:id_by_slug', `${entityPrefixes[pageContext.routeParams.entityType]}${pageContext.routeParams.entitySlug}`); if (!entityId) { throw render(404, `Cannot find ${pageContext.routeParams.entityType} '${pageContext.routeParams.entitySlug}'.`); diff --git a/pages/entities/@entitySlug/+route.js b/pages/entities/@entitySlug/+route.js index cb31f26..eed004f 100644 --- a/pages/entities/@entitySlug/+route.js +++ b/pages/entities/@entitySlug/+route.js @@ -1,7 +1,7 @@ import { match } from 'path-to-regexp'; // import { resolveRoute } from 'vike/routing'; // eslint-disable-line import/extensions -const path = '/:entityType(channel|network)/:entitySlug/:domain(scenes|movies|series)?/:scope?/:page?'; +const path = '/:entityType(channel|network|studio)/:entitySlug/:domain(scenes|movies|series)?/:scope?/:page?'; const urlMatch = match(path, { decode: decodeURIComponent }); export default (pageContext) => { diff --git a/pages/scene/+Page.vue b/pages/scene/+Page.vue index d0fb71c..99bb735 100644 --- a/pages/scene/+Page.vue +++ b/pages/scene/+Page.vue @@ -205,6 +205,18 @@ {{ scene.shootId }}
    +
    +

    Studio

    + + {{ scene.studio.name }} +
    +
    entity.id === scene.entity_id); + const sceneStudio = studios.find((entity) => entity.id === scene.studio_id); const sceneActors = actors.filter((actor) => actor.release_id === sceneId); const sceneDirectors = directors.filter((director) => director.release_id === sceneId); const sceneTags = tags.filter((tag) => tag.release_id === sceneId); @@ -280,6 +293,7 @@ export async function fetchScenesById(sceneIds, { reqUser, ...context } = {}) { return curateScene(scene, { channel: sceneChannel, + studio: sceneStudio, actors: sceneActors, directors: sceneDirectors, tags: sceneTags, @@ -339,7 +353,8 @@ async function queryManticoreSql(filters, options, _reqUser) { :yearsFacet: :actorsFacet: :tagsFacet: - :channelsFacet:; + :channelsFacet: + :studiosFacet:; show meta; `, { query: knexManticore(filters.stashId ? 'scenes_stashed' : 'scenes') @@ -470,6 +485,7 @@ async function queryManticoreSql(filters, options, _reqUser) { actorsFacet: options.aggregateActors ? knex.raw('facet scenes.actor_ids order by count(*) desc limit ?', [aggSize]) : null, tagsFacet: options.aggregateTags ? knex.raw('facet scenes.tag_ids order by count(*) desc limit ?', [aggSize]) : null, channelsFacet: options.aggregateChannels ? knex.raw('facet scenes.channel_id order by count(*) desc limit ?', [aggSize]) : null, + studiosFacet: options.aggregateChannels ? knex.raw('facet scenes.studio_id order by count(*) desc limit ?', [aggSize]) : null, maxMatches: config.database.manticore.maxMatches, maxQueryTime: config.database.manticore.maxQueryTime, }).toString(); @@ -507,6 +523,13 @@ async function queryManticoreSql(filters, options, _reqUser) { ?.data.map((row) => ({ key: row.channel_id || row['scenes.channel_id'], doc_count: row['count(*)'] })) || []; + const studioIds = results + .find((result) => (result.columns[0].studio_id || result.columns[0]['scenes.studio_id']) && result.columns[1]['count(*)']) + ?.data + .map((row) => ({ key: row.studio_id || row['scenes.studio_id'], doc_count: row['count(*)'] })) + .filter((row) => !!row.key) + || []; + const total = Number(results.at(-1).data.find((entry) => entry.Variable_name === 'total_found')?.Value) || 0; return { @@ -517,6 +540,7 @@ async function queryManticoreSql(filters, options, _reqUser) { actorIds, tagIds, channelIds, + studioIds, }, }; } @@ -540,19 +564,24 @@ export async function fetchScenes(filters, rawOptions, reqUser) { console.timeEnd('manticore sql'); const aggYears = options.aggregateYears && result.aggregations.years.map((bucket) => ({ year: bucket.key, count: bucket.doc_count })); + const entityIds = options.aggregateChannels && [...(result.aggregations.channelIds || []), ...(result.aggregations.studioIds || [])]; const actorCounts = options.aggregateActors && countAggregations(result.aggregations?.actorIds); const tagCounts = options.aggregateTags && countAggregations(result.aggregations?.tagIds); - const channelCounts = options.aggregateChannels && countAggregations(result.aggregations?.channelIds); + const channelCounts = options.aggregateChannels && countAggregations(entityIds); + + console.log('entity ids', entityIds); console.time('fetch aggregations'); const [aggActors, aggTags, aggChannels] = await Promise.all([ options.aggregateActors ? fetchActorsById(result.aggregations.actorIds.map((bucket) => bucket.key), { order: ['slug', 'asc'], append: actorCounts }) : [], options.aggregateTags ? fetchTagsById(result.aggregations.tagIds.map((bucket) => bucket.key), { order: [knex.raw('lower(name)'), 'asc'], append: tagCounts }) : [], - options.aggregateChannels ? fetchEntitiesById(result.aggregations.channelIds.map((bucket) => bucket.key), { order: ['slug', 'asc'], append: channelCounts }) : [], + options.aggregateChannels ? fetchEntitiesById(entityIds.map((bucket) => bucket.key), { order: ['slug', 'asc'], append: channelCounts }) : [], ]); + console.log('studio ids', aggChannels.filter((studio) => studio.slug === 'wgcz')); + console.timeEnd('fetch aggregations'); console.time('fetch full'); diff --git a/static b/static index 5e1b219..333d260 160000 --- a/static +++ b/static @@ -1 +1 @@ -Subproject commit 5e1b2190f0d580321a310c1c1fc95ede8f33473b +Subproject commit 333d2604c8987548786434c78162118f50c94bc8