1
0
Fork 0
forked from OpenNeo/impress

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
parent bc5241d087
commit 578c59ce04

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) {