diff --git a/pages/search/+onBeforeRender.js b/pages/search/+onBeforeRender.js index 3ea908d..d7bd9f9 100644 --- a/pages/search/+onBeforeRender.js +++ b/pages/search/+onBeforeRender.js @@ -22,7 +22,7 @@ export async function onBeforeRender(pageContext) { return { pageContext: { - title: `Search '${pageContext.urlParsed.search.q}'`, + title: `Search '${pageContext.urlParsed.search.q || ''}'`, pageProps: { scenes, aggActors, diff --git a/src/cache.js b/src/cache.js index 501bd49..01656d4 100644 --- a/src/cache.js +++ b/src/cache.js @@ -6,9 +6,11 @@ export async function getIdsBySlug(slugs, domain) { return null; } + /* this, naturally, fails if the slug is 69 etc. if (Number(slug)) { return Number(slug); // already an ID or missing } + */ const id = await redis.hGet(`traxxx:${domain}:id_by_slug`, slug); diff --git a/src/movies.js b/src/movies.js index d51f864..9781f99 100644 --- a/src/movies.js +++ b/src/movies.js @@ -532,9 +532,9 @@ export async function fetchMovies(filters, rawOptions, reqUser) { const channelCounts = options.aggregateChannels && countAggregations(result.aggregations?.channelIds); const [aggActors, aggTags, aggChannels] = await Promise.all([ - options.aggregateActors ? fetchActorsById(result.aggregations.actorIds.map((bucket) => bucket.key), { order: ['name', 'asc'], append: actorCounts }) : [], - options.aggregateTags ? fetchTagsById(result.aggregations.tagIds.map((bucket) => bucket.key), { order: ['name', 'asc'], append: tagCounts }) : [], - options.aggregateChannels ? fetchEntitiesById(result.aggregations.channelIds.map((bucket) => bucket.key), { order: ['name', 'asc'], append: channelCounts }) : [], + 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 }) : [], ]); const movieIds = result.movies.map((movie) => Number(movie.id)); diff --git a/src/scenes.js b/src/scenes.js index a00562e..40aa14e 100644 --- a/src/scenes.js +++ b/src/scenes.js @@ -574,9 +574,9 @@ export async function fetchScenes(filters, rawOptions, reqUser) { console.time('fetch aggregations'); const [aggActors, aggTags, aggChannels] = await Promise.all([ - options.aggregateActors ? fetchActorsById(result.aggregations.actorIds.map((bucket) => bucket.key), { order: ['name', 'asc'], append: actorCounts }) : [], - options.aggregateTags ? fetchTagsById(result.aggregations.tagIds.map((bucket) => bucket.key), { order: ['name', 'asc'], append: tagCounts }) : [], - options.aggregateChannels ? fetchEntitiesById(result.aggregations.channelIds.map((bucket) => bucket.key), { order: ['name', 'asc'], append: channelCounts }) : [], + 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 }) : [], ]); console.timeEnd('fetch aggregations');