Using paginated full text search for movies, combined actor search and fetch to allow combining search with filters.
This commit is contained in:
@@ -289,7 +289,7 @@ function initActorActions(store, router) {
|
||||
async function fetchActors({ _commit }, {
|
||||
limit = 10,
|
||||
pageNumber = 1,
|
||||
letter,
|
||||
query,
|
||||
gender,
|
||||
age,
|
||||
dob,
|
||||
@@ -332,24 +332,23 @@ function initActorActions(store, router) {
|
||||
|
||||
const { connection: { actors, totalCount } } = await graphql(`
|
||||
query Actors(
|
||||
$query: String
|
||||
$limit: Int,
|
||||
$offset: Int = 0,
|
||||
$letter: String! = "",
|
||||
$naturalBoobs: Boolean,
|
||||
$userId: Int,
|
||||
$hasAuth: Boolean!,
|
||||
) {
|
||||
connection: actorsConnection(
|
||||
connection: searchActorsConnection(
|
||||
query: $query
|
||||
first: $limit,
|
||||
offset: $offset
|
||||
orderBy: NAME_ASC
|
||||
minLength: 0
|
||||
filter: {
|
||||
aliasFor: {
|
||||
isNull: true
|
||||
}
|
||||
name: {
|
||||
startsWith: $letter
|
||||
}
|
||||
${genderFilter}
|
||||
${ageFilter}
|
||||
${dobFilter}
|
||||
@@ -410,9 +409,9 @@ function initActorActions(store, router) {
|
||||
}
|
||||
}
|
||||
`, {
|
||||
query,
|
||||
offset: Math.max(0, (pageNumber - 1)) * limit,
|
||||
limit,
|
||||
letter,
|
||||
naturalBoobs,
|
||||
hasAuth: !!store.state.auth.user,
|
||||
userId: store.state.auth.user?.id,
|
||||
@@ -424,96 +423,6 @@ function initActorActions(store, router) {
|
||||
};
|
||||
}
|
||||
|
||||
async function searchActors({ _commit }, { query, limit = 20, minLength = 2 }) {
|
||||
const { actors } = await graphql(`
|
||||
query SearchActors(
|
||||
$query: String!
|
||||
$limit: Int = 20
|
||||
$minLength: Int = 2
|
||||
$hasAuth: Boolean!
|
||||
$userId: Int
|
||||
) {
|
||||
actors: searchActors(
|
||||
search: $query,
|
||||
minLength: $minLength
|
||||
first: $limit
|
||||
orderBy: NAME_ASC
|
||||
) {
|
||||
id
|
||||
name
|
||||
slug
|
||||
dateOfBirth
|
||||
ageFromBirth
|
||||
ageAtDeath
|
||||
dateOfBirth
|
||||
dateOfDeath
|
||||
gender
|
||||
aliasFor: actorByAliasFor {
|
||||
id
|
||||
name
|
||||
slug
|
||||
age
|
||||
ageAtDeath
|
||||
dateOfBirth
|
||||
dateOfDeath
|
||||
gender
|
||||
entity {
|
||||
id
|
||||
name
|
||||
slug
|
||||
}
|
||||
avatar: avatarMedia {
|
||||
id
|
||||
path
|
||||
thumbnail
|
||||
lazy
|
||||
isS3
|
||||
width
|
||||
height
|
||||
comment
|
||||
credit
|
||||
}
|
||||
birthCountry: countryByBirthCountryAlpha2 {
|
||||
alpha2
|
||||
name
|
||||
alias
|
||||
}
|
||||
}
|
||||
entity {
|
||||
id
|
||||
name
|
||||
slug
|
||||
}
|
||||
avatar: avatarMedia {
|
||||
id
|
||||
path
|
||||
thumbnail
|
||||
lazy
|
||||
isS3
|
||||
width
|
||||
height
|
||||
comment
|
||||
credit
|
||||
}
|
||||
birthCountry: countryByBirthCountryAlpha2 {
|
||||
alpha2
|
||||
name
|
||||
alias
|
||||
}
|
||||
${actorStashesFields}
|
||||
}
|
||||
}
|
||||
`, {
|
||||
query,
|
||||
limit,
|
||||
minLength,
|
||||
hasAuth: !!store.state.auth.user,
|
||||
userId: store.state.auth.user?.id,
|
||||
});
|
||||
|
||||
return actors.map(actor => curateActor(actor));
|
||||
}
|
||||
|
||||
async function fetchActorReleases({ _commit }, actorId) {
|
||||
const releases = await get(`/actors/${actorId}/releases`, {
|
||||
filter: store.state.ui.filter,
|
||||
@@ -528,7 +437,6 @@ function initActorActions(store, router) {
|
||||
fetchActorById,
|
||||
fetchActors,
|
||||
fetchActorReleases,
|
||||
searchActors,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user