File tree Expand file tree Collapse file tree
app/domain/export/tabular/people
spec/domain/export/tabular/people Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -95,18 +95,26 @@ def mitglied_or_abonnent_condition
9595 <<-SQL . squish ,
9696 (roles.type = :mitglied_type AND
9797 (roles.beitragskategorie <> :beitragskategorie OR people.sac_family_main_person) AND
98- (subscriptions.mailing_list_id IS NULL OR
99- subscriptions.mailing_list_id <> :mailing_list_id OR
100- NOT subscriptions.excluded)) OR
98+ NOT people.id IN (:excluded_from_mailing_list)) OR
10199 roles.type IN (:abonnent_types)
102100 SQL
103101 mitglied_type : SacCas ::MITGLIED_STAMMSEKTION_ROLES . map ( &:sti_name ) ,
104102 beitragskategorie : SacCas ::Beitragskategorie ::Calculator ::CATEGORY_FAMILY ,
105- mailing_list_id : sac_magazine_mailing_list_id ,
103+ excluded_from_mailing_list : ,
106104 abonnent_types : SacCas ::ABONNENT_MAGAZIN_ROLES . map ( &:sti_name )
107105 ]
108106 end
109107
108+ def excluded_from_mailing_list
109+ Subscription
110+ . where (
111+ mailing_list_id : sac_magazine_mailing_list_id ,
112+ excluded : true ,
113+ subscriber_type : "Person"
114+ )
115+ . select ( :subscriber_id )
116+ end
117+
110118 def language_condition ( lang , abo_group_ids )
111119 [
112120 <<-SQL . squish ,
Original file line number Diff line number Diff line change 2828 start_on : "2020-03-24" ) . person
2929 end
3030 let! ( :mitglied_fr ) do
31- Fabricate ( "Group::SektionsMitglieder::Mitglied" ,
31+ p = Fabricate ( "Group::SektionsMitglieder::Mitglied" ,
3232 beitragskategorie : :adult ,
3333 person : Fabricate ( :person , language : "fr" ) ,
3434 group : sektion ,
3535 start_on : "2020-03-25" ) . person
36+ mailing_lists ( :newsletter ) . subscriptions . create! ( subscriber : p ) # other subscription
37+ p
3638 end
3739 let! ( :mitglied_france ) do
3840 Fabricate ( "Group::SektionsMitglieder::Mitglied" ,
4749 group : sektion ,
4850 start_on : "2020-03-27" ) . person
4951 mailing_lists ( :sac_magazine ) . subscriptions . create! ( subscriber : p , excluded : true )
52+ mailing_lists ( :newsletter ) . subscriptions . create! ( subscriber : p ) # other subscription
5053 p
5154 end
5255 let! ( :new_entry ) do
You can’t perform that action at this time.
0 commit comments