watched_refine: refineFilterStatus: Remove parenthesis around WHERE query.

It looks like GORM already adds the parenthesis around this for us in the final query, so ours was unnecessary
This commit is contained in:
IRHM
2026-07-18 10:43:30 +01:00
committed by momi
parent bf0594c1e8
commit 9b64932af1
+8 -5
View File
@@ -61,17 +61,20 @@ func refineFilterStatus(
userSettings != nil && util.Deref(userSettings.IncludePreviouslyWatched, false) {
slog.Debug("refineFilterStatus: Performing query that includes previously watched.")
db.
// The WHERE here is wrapped in parenthesis so that the `OR` doesn't
// intefere with the main query confusing its AND/ORs.
Where(`(watcheds.status IN ? OR EXISTS (
// If status IN `f` OR any activity counts as a play for this
// watched item.
// NOTE: GORM adds parenthesis around this WHERE so that the OR
// doesn't confuse the whole WHERE on the main query, so we don't
// need to do that.
Where(`watcheds.status IN ? OR EXISTS (
SELECT 1
FROM activities
WHERE activities.watched_id = watcheds.id
AND activities.count_as_play = 1
))`, f)
)`, f)
} else {
slog.Debug("refineFilterStatus: Performing standard query.")
db.Where(`watcheds.status IN ?`, f)
db.Where("watcheds.status IN ?", f)
}
}