@@ -68,56 +68,22 @@ class Item < ApplicationRecord
6868
6969 scope :by_size , -> ( size ) { joins ( :base_item ) . where ( base_items : { size : size } ) }
7070
71- # Scopes - explanation of business rules for filtering scopes as of 20240527. This was a mess, but is much better now.
72- # 1/ Disposable. Disposables are only the disposable diapers for children. So we deliberately exclude adult and cloth
73- # 2/ Cloth. Cloth diapers for children. Exclude adult cloth. Cloth training pants also go here.
74- # 3/ Adult incontinence. Items for adult incontinence -- diapers, ai pads, but not adult wipes.
75- # 4/ Period supplies. All things with 'menstrual in the category'
76- # 5/ Other -- Miscellaneous, and wipes
77- # Known holes and ambiguities as of 20240527. Working on these with the business
78- # 1/ Liners. We are adding a new item for AI liners, and renaming the current liners to be specifically for periods,
79- # having confirmed with the business that the majority of liners are for menstrual use.
80- # However, there is a product which can be used for either, so we are still sussing out what to do about that.
81-
82- scope :disposable , -> {
83- joins ( :base_item )
84- . where ( "lower(base_items.category) LIKE '%diaper%'" )
85- . where . not ( "lower(base_items.category) LIKE '%cloth%' OR lower(base_items.name) LIKE '%cloth%'" )
86- . where . not ( "lower(base_items.category) LIKE '%adult%'" )
87- }
88-
89- scope :cloth_diapers , -> {
90- joins ( :base_item )
91- . where ( "lower(base_items.category) LIKE '%cloth%'" )
92- . or ( where ( "base_items.category = 'Training Pants'" ) )
93- . where . not ( "lower(base_items.category) LIKE '%adult%'" )
94- }
95-
96- scope :adult_incontinence , -> {
97- joins ( :base_item )
98- . where ( "lower(base_items.category) LIKE '%adult%' AND lower(base_items.category) NOT LIKE '%wipes%'" )
99- }
100-
10171 scope :period_supplies , -> {
102- joins ( :base_item )
103- . where ( "lower(base_items.category) LIKE '%menstrual%'" )
104- }
105-
106- scope :other_categories , -> {
107- joins ( :base_item )
108- . where ( "lower(base_items.category) LIKE '%wipes%'" )
109- . or ( where ( "base_items.category = 'Miscellaneous'" ) )
72+ where ( reporting_category : [ :pads , :tampons , :period_liners , :period_underwear , :period_other ] )
11073 }
11174
11275 enum :reporting_category , {
11376 adult_incontinence : "adult_incontinence" ,
11477 cloth_diapers : "cloth_diapers" ,
11578 disposable_diapers : "disposable_diapers" ,
11679 menstrual : "menstrual" ,
117- other : "other" ,
80+ other_categories : "other" ,
11881 pads : "pads" ,
82+ period_liners : "period_liners" ,
83+ period_other : "period_other" ,
84+ period_underwear : "period_underwear" ,
11985 tampons : "tampons"
120- } , scopes : false , instance_methods : false
86+ } , instance_methods : false
12187
12288 def self . reactivate ( item_ids )
12389 item_ids = Array . wrap ( item_ids )
0 commit comments