From 4c61353e27548fe4556f0e894956a524f629022f Mon Sep 17 00:00:00 2001 From: Herpes3000 <61895715+randemgame@users.noreply.github.com> Date: Sat, 19 Oct 2024 19:08:51 +0300 Subject: [PATCH] Update Scenes' 'Updated At' Date on Heatmap Gen & Expand Error Log The UpdatedAt field of a scene is now correctly updated after Generate Task is run and a heatmap linked to a scene.. I thought it made more sense here in the generate heatmap compared to scan.go, owing to funscript data not being tracked/stored in a typical sense with the scan message "updating metadata". I used a simplified error messaging as I did not think it was critcal but I do not know if did not use the correct code structure If updating the UpdatedAt field should be done there when the file is marked as interactive I can try and do that? This would fix this long-standing issue https://github.com/stashapp/stash/issues/3738 The error message change is useful as I could not tell which scripts were causing errors before but now it is clear in the logs --- .../task_generate_interactive_heatmap_speed.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/internal/manager/task_generate_interactive_heatmap_speed.go b/internal/manager/task_generate_interactive_heatmap_speed.go index 61350f09c2b..22bb9e69977 100644 --- a/internal/manager/task_generate_interactive_heatmap_speed.go +++ b/internal/manager/task_generate_interactive_heatmap_speed.go @@ -3,6 +3,7 @@ package manager import ( "context" "fmt" + "time" "github.com/stashapp/stash/pkg/file/video" "github.com/stashapp/stash/pkg/fsutil" @@ -36,7 +37,7 @@ func (t *GenerateInteractiveHeatmapSpeedTask) Start(ctx context.Context) { err := generator.Generate(funscriptPath, heatmapPath, t.Scene.Files.Primary().Duration) if err != nil { - logger.Errorf("error generating heatmap: %s", err.Error()) + logger.Errorf("error generating heatmap for %s: %s", t.Scene.Path, err.Error()) return } @@ -51,6 +52,18 @@ func (t *GenerateInteractiveHeatmapSpeedTask) Start(ctx context.Context) { }); err != nil && ctx.Err() == nil { logger.Error(err.Error()) } + + if err := r.WithTxn(ctx, func(ctx context.Context) error { + qb := r.Scene + scenePartial := models.NewScenePartial() + now := time.Now() + scenePartial.UpdatedAt = models.NewOptionalTime(now) + + _, err := qb.UpdatePartial(ctx, t.Scene.ID, scenePartial) + return err + }); err != nil && ctx.Err() == nil { + logger.Errorf("error updating %s after heatmap generation: %s", t.Scene.Path, err.Error()) + } } func (t *GenerateInteractiveHeatmapSpeedTask) required() bool {