2019-02-09 12:30:49 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"strconv"
|
2019-11-07 12:49:08 +00:00
|
|
|
|
|
|
|
"github.com/stashapp/stash/pkg/manager"
|
|
|
|
"github.com/stashapp/stash/pkg/models"
|
2019-02-09 12:30:49 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func (r *queryResolver) FindScene(ctx context.Context, id *string, checksum *string) (*models.Scene, error) {
|
|
|
|
qb := models.NewSceneQueryBuilder()
|
|
|
|
var scene *models.Scene
|
|
|
|
var err error
|
|
|
|
if id != nil {
|
2019-12-21 00:13:23 +00:00
|
|
|
idInt, _ := strconv.Atoi(*id)
|
2019-02-09 12:30:49 +00:00
|
|
|
scene, err = qb.Find(idInt)
|
|
|
|
} else if checksum != nil {
|
|
|
|
scene, err = qb.FindByChecksum(*checksum)
|
|
|
|
}
|
|
|
|
return scene, err
|
|
|
|
}
|
|
|
|
|
2019-03-26 15:35:06 +00:00
|
|
|
func (r *queryResolver) FindScenes(ctx context.Context, sceneFilter *models.SceneFilterType, sceneIds []int, filter *models.FindFilterType) (*models.FindScenesResultType, error) {
|
2019-02-09 12:30:49 +00:00
|
|
|
qb := models.NewSceneQueryBuilder()
|
2019-03-26 15:35:06 +00:00
|
|
|
scenes, total := qb.Query(sceneFilter, 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
|
|
|
}
|
2019-10-30 13:37:21 +00:00
|
|
|
|
|
|
|
func (r *queryResolver) FindScenesByPathRegex(ctx context.Context, filter *models.FindFilterType) (*models.FindScenesResultType, error) {
|
|
|
|
qb := models.NewSceneQueryBuilder()
|
|
|
|
|
|
|
|
scenes, total := qb.QueryByPathRegex(filter)
|
|
|
|
return &models.FindScenesResultType{
|
|
|
|
Count: total,
|
|
|
|
Scenes: scenes,
|
|
|
|
}, nil
|
|
|
|
}
|
2019-11-07 12:49:08 +00:00
|
|
|
|
|
|
|
func (r *queryResolver) ParseSceneFilenames(ctx context.Context, filter *models.FindFilterType, config models.SceneParserInput) (*models.SceneParserResultType, error) {
|
|
|
|
parser := manager.NewSceneFilenameParser(filter, config)
|
|
|
|
|
|
|
|
result, count, err := parser.Parse()
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &models.SceneParserResultType{
|
|
|
|
Count: count,
|
|
|
|
Results: result,
|
|
|
|
}, nil
|
|
|
|
}
|