2024-02-22 04:09:24 +00:00
|
|
|
import { fetchScenes } from '#/src/scenes.js';
|
2024-06-02 03:22:08 +00:00
|
|
|
import { fetchActors } from '#/src/actors.js';
|
|
|
|
import { fetchMovies } from '#/src/movies.js';
|
2024-02-22 04:09:24 +00:00
|
|
|
import { curateScenesQuery } from '#/src/web/scenes.js';
|
2024-06-02 03:22:08 +00:00
|
|
|
import { curateActorsQuery } from '#/src/web/actors.js';
|
|
|
|
import { curateMoviesQuery } from '#/src/web/movies.js';
|
2024-02-22 04:09:24 +00:00
|
|
|
|
|
|
|
export async function onBeforeRender(pageContext) {
|
2024-06-02 03:22:08 +00:00
|
|
|
const [searchScenes, searchActors, searchMovies] = await Promise.all([
|
|
|
|
fetchScenes(await curateScenesQuery({
|
|
|
|
...pageContext.urlQuery,
|
|
|
|
query: pageContext.urlParsed.search.q,
|
|
|
|
scope: pageContext.urlParsed.search.scope || 'results',
|
|
|
|
tagFilter: pageContext.tagFilter,
|
|
|
|
}), {
|
|
|
|
page: Number(pageContext.routeParams.page) || 1,
|
|
|
|
limit: Number(pageContext.urlParsed.search.limit) || 15,
|
|
|
|
}, pageContext.user),
|
|
|
|
fetchActors(curateActorsQuery(pageContext.urlQuery), {
|
|
|
|
page: Number(pageContext.routeParams.page) || 1,
|
|
|
|
limit: Number(pageContext.urlParsed.search.limit) || 10,
|
|
|
|
order: ['results', 'desc'],
|
|
|
|
}, pageContext.user),
|
|
|
|
fetchMovies(await curateMoviesQuery({
|
|
|
|
...pageContext.urlQuery,
|
|
|
|
scope: pageContext.routeParams.scope || 'results',
|
|
|
|
}), {
|
|
|
|
page: Number(pageContext.routeParams.page) || 1,
|
|
|
|
limit: Number(pageContext.urlParsed.search.limit) || 5,
|
|
|
|
}, pageContext.user),
|
|
|
|
]);
|
2024-02-22 04:09:24 +00:00
|
|
|
|
|
|
|
const {
|
|
|
|
scenes,
|
|
|
|
aggActors,
|
|
|
|
aggTags,
|
|
|
|
aggChannels,
|
2024-06-02 03:22:08 +00:00
|
|
|
total: sceneTotal,
|
2024-02-22 04:09:24 +00:00
|
|
|
} = searchScenes;
|
|
|
|
|
2024-06-02 03:22:08 +00:00
|
|
|
const {
|
|
|
|
actors,
|
|
|
|
total: actorTotal,
|
|
|
|
} = searchActors;
|
|
|
|
|
|
|
|
const {
|
|
|
|
movies,
|
|
|
|
total: movieTotal,
|
|
|
|
} = searchMovies;
|
|
|
|
|
2024-02-22 04:09:24 +00:00
|
|
|
return {
|
|
|
|
pageContext: {
|
2024-03-27 22:54:23 +00:00
|
|
|
title: `Search '${pageContext.urlParsed.search.q || ''}'`,
|
2024-02-22 04:09:24 +00:00
|
|
|
pageProps: {
|
2024-06-02 03:22:08 +00:00
|
|
|
actors,
|
2024-02-22 04:09:24 +00:00
|
|
|
scenes,
|
2024-06-02 03:22:08 +00:00
|
|
|
movies,
|
2024-02-22 04:09:24 +00:00
|
|
|
aggActors,
|
|
|
|
aggTags,
|
|
|
|
aggChannels,
|
2024-06-02 03:22:08 +00:00
|
|
|
sceneTotal,
|
|
|
|
actorTotal,
|
|
|
|
movieTotal,
|
2024-02-22 04:09:24 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|