2019-02-09 12:30:49 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2019-02-14 23:42:52 +00:00
|
|
|
"github.com/stashapp/stash/pkg/models"
|
2019-02-09 12:30:49 +00:00
|
|
|
"strconv"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (r *queryResolver) FindScene(ctx context.Context, id *string, checksum *string) (*models.Scene, error) {
|
|
|
|
qb := models.NewSceneQueryBuilder()
|
|
|
|
idInt, _ := strconv.Atoi(*id)
|
|
|
|
var scene *models.Scene
|
|
|
|
var err error
|
|
|
|
if id != nil {
|
|
|
|
scene, err = qb.Find(idInt)
|
|
|
|
} else if checksum != nil {
|
|
|
|
scene, err = qb.FindByChecksum(*checksum)
|
|
|
|
}
|
|
|
|
return scene, err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *queryResolver) FindScenes(ctx context.Context, scene_filter *models.SceneFilterType, scene_ids []int, filter *models.FindFilterType) (models.FindScenesResultType, error) {
|
|
|
|
qb := models.NewSceneQueryBuilder()
|
|
|
|
scenes, total := qb.Query(scene_filter, filter)
|
|
|
|
return models.FindScenesResultType{
|
2019-02-14 22:53:32 +00:00
|
|
|
Count: total,
|
2019-02-09 12:30:49 +00:00
|
|
|
Scenes: scenes,
|
|
|
|
}, nil
|
2019-02-14 22:53:32 +00:00
|
|
|
}
|