mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
@@ -117,10 +117,7 @@ func (r *queryResolver) SceneMarkerTags(ctx context.Context, scene_id string) ([
|
||||
var keys []int
|
||||
tqb := models.NewTagQueryBuilder()
|
||||
for _, sceneMarker := range sceneMarkers {
|
||||
if !sceneMarker.PrimaryTagID.Valid {
|
||||
panic("missing primary tag id")
|
||||
}
|
||||
markerPrimaryTag, err := tqb.Find(int(sceneMarker.PrimaryTagID.Int64), nil)
|
||||
markerPrimaryTag, err := tqb.Find(sceneMarker.PrimaryTagID, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -18,10 +18,7 @@ func (r *sceneMarkerResolver) Scene(ctx context.Context, obj *models.SceneMarker
|
||||
|
||||
func (r *sceneMarkerResolver) PrimaryTag(ctx context.Context, obj *models.SceneMarker) (*models.Tag, error) {
|
||||
qb := models.NewTagQueryBuilder()
|
||||
if !obj.PrimaryTagID.Valid {
|
||||
panic("TODO no primary tag id")
|
||||
}
|
||||
tag, err := qb.Find(int(obj.PrimaryTagID.Int64), nil) // TODO make primary tag id not null in DB
|
||||
tag, err := qb.Find(obj.PrimaryTagID, nil)
|
||||
return tag, err
|
||||
}
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ func (r *mutationResolver) SceneMarkerCreate(ctx context.Context, input models.S
|
||||
newSceneMarker := models.SceneMarker{
|
||||
Title: input.Title,
|
||||
Seconds: input.Seconds,
|
||||
PrimaryTagID: sql.NullInt64{Int64: int64(primaryTagID), Valid: primaryTagID != 0},
|
||||
PrimaryTagID: primaryTagID,
|
||||
SceneID: sql.NullInt64{Int64: int64(sceneID), Valid: sceneID != 0},
|
||||
CreatedAt: models.SQLiteTimestamp{Timestamp: currentTime},
|
||||
UpdatedAt: models.SQLiteTimestamp{Timestamp: currentTime},
|
||||
@@ -127,7 +127,7 @@ func (r *mutationResolver) SceneMarkerUpdate(ctx context.Context, input models.S
|
||||
Title: input.Title,
|
||||
Seconds: input.Seconds,
|
||||
SceneID: sql.NullInt64{Int64: int64(sceneID), Valid: sceneID != 0},
|
||||
PrimaryTagID: sql.NullInt64{Int64: int64(primaryTagID), Valid: primaryTagID != 0},
|
||||
PrimaryTagID: primaryTagID,
|
||||
UpdatedAt: models.SQLiteTimestamp{Timestamp: time.Now()},
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ func changeMarker(ctx context.Context, changeType int, changedMarker models.Scen
|
||||
var markerTagJoins []models.SceneMarkersTags
|
||||
for _, tid := range tagIds {
|
||||
tagID, _ := strconv.Atoi(tid)
|
||||
if int64(tagID) == changedMarker.PrimaryTagID.Int64 {
|
||||
if tagID == changedMarker.PrimaryTagID {
|
||||
continue // If this tag is the primary tag, then let's not add it.
|
||||
}
|
||||
markerTag := models.SceneMarkersTags{
|
||||
|
||||
@@ -70,7 +70,7 @@ CREATE TABLE `scene_markers` (
|
||||
`id` integer not null primary key autoincrement,
|
||||
`title` varchar(255) not null,
|
||||
`seconds` float not null,
|
||||
`primary_tag_id` integer,
|
||||
`primary_tag_id` integer not null,
|
||||
`scene_id` integer,
|
||||
`created_at` datetime not null,
|
||||
`updated_at` datetime not null,
|
||||
|
||||
@@ -109,11 +109,7 @@ func (t *ExportTask) ExportScenes(ctx context.Context) {
|
||||
newSceneJSON.Tags = t.getTagNames(tags)
|
||||
|
||||
for _, sceneMarker := range sceneMarkers {
|
||||
var primaryTagID int
|
||||
if sceneMarker.PrimaryTagID.Valid {
|
||||
primaryTagID = int(sceneMarker.PrimaryTagID.Int64)
|
||||
}
|
||||
primaryTag, err := tagQB.Find(primaryTagID, tx)
|
||||
primaryTag, err := tagQB.Find(sceneMarker.PrimaryTagID, tx)
|
||||
if err != nil {
|
||||
logger.Errorf("[scenes] <%s> invalid primary tag for scene marker: %s", scene.Checksum, err.Error())
|
||||
continue
|
||||
|
||||
@@ -519,7 +519,7 @@ func (t *ImportTask) ImportScenes(ctx context.Context) {
|
||||
if err != nil {
|
||||
logger.Errorf("[scenes] <%s> failed to find primary tag for marker: %s", scene.Checksum, err.Error())
|
||||
} else {
|
||||
newSceneMarker.PrimaryTagID = sql.NullInt64{Int64: int64(primaryTag.ID), Valid: true}
|
||||
newSceneMarker.PrimaryTagID = primaryTag.ID
|
||||
}
|
||||
|
||||
// Create the scene marker in the DB
|
||||
|
||||
@@ -8,7 +8,7 @@ type SceneMarker struct {
|
||||
ID int `db:"id" json:"id"`
|
||||
Title string `db:"title" json:"title"`
|
||||
Seconds float64 `db:"seconds" json:"seconds"`
|
||||
PrimaryTagID sql.NullInt64 `db:"primary_tag_id,omitempty" json:"primary_tag_id"`
|
||||
PrimaryTagID int `db:"primary_tag_id" json:"primary_tag_id"`
|
||||
SceneID sql.NullInt64 `db:"scene_id,omitempty" json:"scene_id"`
|
||||
CreatedAt SQLiteTimestamp `db:"created_at" json:"created_at"`
|
||||
UpdatedAt SQLiteTimestamp `db:"updated_at" json:"updated_at"`
|
||||
|
||||
Reference in New Issue
Block a user