From da4773f0fc4d61e7747c3c9ff3bdc5669c809c1b Mon Sep 17 00:00:00 2001 From: toshski <104477758+toshski@users.noreply.github.com> Date: Mon, 6 Nov 2023 02:28:26 +1300 Subject: [PATCH] feat: Add "Has Favourite Actor" Scene Filter Attribute (#1438) --- pkg/api/scenes.go | 1 + pkg/models/model_scene.go | 2 ++ 2 files changed, 3 insertions(+) diff --git a/pkg/api/scenes.go b/pkg/api/scenes.go index a596588b0..03ec3bff3 100644 --- a/pkg/api/scenes.go +++ b/pkg/api/scenes.go @@ -371,6 +371,7 @@ func (i SceneResource) getFilters(req *restful.Request, resp *restful.Response) outAttributes = append(outAttributes, "Has Script Download") outAttributes = append(outAttributes, "Has AI Generated Script") outAttributes = append(outAttributes, "Has Human Generated Script") + outAttributes = append(outAttributes, "Has Favourite Actor") type Results struct { Result string } diff --git a/pkg/models/model_scene.go b/pkg/models/model_scene.go index 3865f1e28..aeb30fecb 100644 --- a/pkg/models/model_scene.go +++ b/pkg/models/model_scene.go @@ -834,6 +834,8 @@ func queryScenes(db *gorm.DB, r RequestSceneList) (*gorm.DB, *gorm.DB) { where = "scenes.ai_script = 1" case "Has Human Generated Script": where = "scenes.human_script = 1" + case "Has Favourite Actor": + where = "exists (select * from scene_cast join actors on actors.id=scene_cast.actor_id where actors.favourite=1 and scene_cast.scene_id=scenes.id)" } if negate {