Using paginated full text search for movies, combined actor search and fetch to allow combining search with filters.

This commit is contained in:
DebaucheryLibrarian
2021-08-22 22:25:20 +02:00
parent e0905ab8fc
commit 6a8c9d89cb
21 changed files with 163 additions and 196 deletions

View File

@@ -100,26 +100,37 @@ function initReleasesActions(store, router) {
};
}
async function searchMovies({ _commit }, { query, limit = 20 }) {
const { movies } = await graphql(`
async function searchMovies({ _commit }, { query, limit = 20, pageNumber = 1 }) {
const { connection: { movies, totalCount } } = await graphql(`
query SearchMovies(
$query: String!
$limit:Int = 20,
$limit:Int = 20
$offset:Int = 0
) {
movies: searchMovies(
connection: searchMoviesConnection(
query: $query
minLength: 1
first: $limit
offset: $offset
orderBy: RANK_DESC
) {
${movieFields}
movies: nodes {
movie {
${movieFields}
}
}
totalCount
}
}
`, {
query,
limit,
offset: Math.max(0, (pageNumber - 1)) * limit,
});
return movies.map(movie => curateRelease(movie));
return {
movies: movies.map(({ movie }) => curateRelease(movie)),
totalCount,
};
}
async function fetchMovieById({ _commit }, movieId) {