mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 20:34:37 +03:00
Add movie count to performer and studio card (#1760)
* Add movies and movie_count properties to Performer type Extend the GraphQL API to allow getting the movies and movie count by performer. * Add movies count to performer card * Add movies and movie_count properties to Studio type Extend the GraphQL API to allow getting the movies and movie count by studio. * Add movies count to studio card
This commit is contained in:
@@ -308,3 +308,42 @@ func (qb *movieQueryBuilder) GetBackImage(movieID int) ([]byte, error) {
|
||||
query := `SELECT back_image from movies_images WHERE movie_id = ?`
|
||||
return getImage(qb.tx, query, movieID)
|
||||
}
|
||||
|
||||
func (qb *movieQueryBuilder) FindByPerformerID(performerID int) ([]*models.Movie, error) {
|
||||
query := `SELECT DISTINCT movies.*
|
||||
FROM movies
|
||||
INNER JOIN movies_scenes ON movies.id = movies_scenes.movie_id
|
||||
INNER JOIN performers_scenes ON performers_scenes.scene_id = movies_scenes.scene_id
|
||||
WHERE performers_scenes.performer_id = ?
|
||||
`
|
||||
args := []interface{}{performerID}
|
||||
return qb.queryMovies(query, args)
|
||||
}
|
||||
|
||||
func (qb *movieQueryBuilder) CountByPerformerID(performerID int) (int, error) {
|
||||
query := `SELECT COUNT(DISTINCT movies_scenes.movie_id) AS count
|
||||
FROM movies_scenes
|
||||
INNER JOIN performers_scenes ON performers_scenes.scene_id = movies_scenes.scene_id
|
||||
WHERE performers_scenes.performer_id = ?
|
||||
`
|
||||
args := []interface{}{performerID}
|
||||
return qb.runCountQuery(query, args)
|
||||
}
|
||||
|
||||
func (qb *movieQueryBuilder) FindByStudioID(studioID int) ([]*models.Movie, error) {
|
||||
query := `SELECT movies.*
|
||||
FROM movies
|
||||
WHERE movies.studio_id = ?
|
||||
`
|
||||
args := []interface{}{studioID}
|
||||
return qb.queryMovies(query, args)
|
||||
}
|
||||
|
||||
func (qb *movieQueryBuilder) CountByStudioID(studioID int) (int, error) {
|
||||
query := `SELECT COUNT(1) AS count
|
||||
FROM movies
|
||||
WHERE movies.studio_id = ?
|
||||
`
|
||||
args := []interface{}{studioID}
|
||||
return qb.runCountQuery(query, args)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user