Oops, fix ambiguous zones_restrict column

When combining occupies and restricts filters, this wouldn't be sure whether to apply to the items or the swf assets.
This commit is contained in:
Matchu 2023-07-29 13:11:53 -07:00 committed by Matchu
parent fd87b41c17
commit 3e728a8e56

View file

@ -96,12 +96,12 @@ class Item < ActiveRecord::Base
}
scope :restricts, ->(zone_label, locale = I18n.locale) {
zone_ids = Zone.matching_label(zone_label, locale).map(&:id)
condition = zone_ids.map { '(SUBSTR(zones_restrict, ?, 1) = "1")' }.join(' OR ')
condition = zone_ids.map { '(SUBSTR(items.zones_restrict, ?, 1) = "1")' }.join(' OR ')
where(condition, *zone_ids)
}
scope :not_restricts, ->(zone_label, locale = I18n.locale) {
zone_ids = Zone.matching_label(zone_label, locale).map(&:id)
condition = zone_ids.map { '(SUBSTR(zones_restrict, ?, 1) = "1")' }.join(' OR ')
condition = zone_ids.map { '(SUBSTR(items.zones_restrict, ?, 1) = "1")' }.join(' OR ')
where("NOT (#{condition})", *zone_ids)
}
scope :fits, ->(body_id) {