Generate content for specific scenes (#672)

* Add UI dialog for scene(s)
* Move preview preset to config
This commit is contained in:
WithoutPants
2020-07-19 11:59:18 +10:00
committed by GitHub
parent 8e4945325d
commit c104c6d075
27 changed files with 552 additions and 148 deletions

View File

@@ -2,6 +2,7 @@ package models
import (
"database/sql"
"fmt"
"strings"
"github.com/jmoiron/sqlx"
@@ -147,6 +148,24 @@ func (qb *SceneQueryBuilder) Find(id int) (*Scene, error) {
return qb.find(id, nil)
}
func (qb *SceneQueryBuilder) FindMany(ids []int) ([]*Scene, error) {
var scenes []*Scene
for _, id := range ids {
scene, err := qb.Find(id)
if err != nil {
return nil, err
}
if scene == nil {
return nil, fmt.Errorf("scene with id %d not found", id)
}
scenes = append(scenes, scene)
}
return scenes, nil
}
func (qb *SceneQueryBuilder) find(id int, tx *sqlx.Tx) (*Scene, error) {
query := selectAll(sceneTable) + "WHERE id = ? LIMIT 1"
args := []interface{}{id}