From 5a89089cf19af6fcd48c7ea25ccd97c970296024 Mon Sep 17 00:00:00 2001 From: Daniel Illi Date: Mon, 16 Sep 2024 17:16:15 +0200 Subject: [PATCH] Add explicit #start_on/#end_on to Role, remove FutureRole, Role#delete_on --- app/domain/statistics/vereinsmitglieder.rb | 4 ++-- spec/domain/abo_addresses/query_spec.rb | 4 ++-- spec/domain/statistics/vereinsmitglieder_spec.rb | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/domain/statistics/vereinsmitglieder.rb b/app/domain/statistics/vereinsmitglieder.rb index 70858cc8..6687cf34 100644 --- a/app/domain/statistics/vereinsmitglieder.rb +++ b/app/domain/statistics/vereinsmitglieder.rb @@ -60,8 +60,8 @@ def person_roles_per_layer_query FROM roles INNER JOIN "groups" "groups" ON "groups".id = roles.group_id INNER JOIN "groups" layers ON layers.id = "groups".layer_group_id - WHERE layers.type = '#{Group::Regionalverein.sti_name}' AND - roles.deleted_at IS NULL AND + #{Role.active.arel.where_sql} AND + layers.type = '#{Group::Regionalverein.sti_name}' AND roles.type IN (#{role_types_param}) GROUP BY "groups".layer_group_id, roles.person_id diff --git a/spec/domain/abo_addresses/query_spec.rb b/spec/domain/abo_addresses/query_spec.rb index 48702ba0..c37cb1f8 100644 --- a/spec/domain/abo_addresses/query_spec.rb +++ b/spec/domain/abo_addresses/query_spec.rb @@ -45,8 +45,8 @@ abos = Fabricate(Group::DachvereinAbonnemente.name.to_sym, parent: groups(:dachverein)) abo = Fabricate(Group::DachvereinAbonnemente::Einzelabo.name.to_sym, group: abos, - created_at: 2.years.ago).person - abo.roles.first.update!(deleted_at: 1.year.ago) + start_on: 2.years.ago, + end_on: 1.year.ago).person is_expected.not_to include(abo) end diff --git a/spec/domain/statistics/vereinsmitglieder_spec.rb b/spec/domain/statistics/vereinsmitglieder_spec.rb index ebb03e3e..bee4e271 100644 --- a/spec/domain/statistics/vereinsmitglieder_spec.rb +++ b/spec/domain/statistics/vereinsmitglieder_spec.rb @@ -68,19 +68,19 @@ (1..6).each { |i| expect(subject.count(groups(:seeland), i)).to eq 0 } end - it "does not count deleted roles" do + it "does not count ended roles" do o = Fabricate(Group::Aktivmitglieder::Aktivmitglied.name.to_sym, group: active, - created_at: 2.years.ago) + start_on: 2.years.ago, + end_on: 1.year.ago) a = Fabricate(Group::Aktivmitglieder::AktivmitgliedOhneAbo.name.to_sym, group: active, person: people(:regio_aktiv), - created_at: 2.years.ago) + start_on: 2.years.ago, + end_on: 1.year.ago) Fabricate(Group::Passivmitglieder::PassivmitgliedMitAbo.name.to_sym, group: passive, person: people(:regio_aktiv)) - o.update!(deleted_at: 1.year.ago) - a.update!(deleted_at: 1.year.ago) (0..5).each { |i| expect(subject.count(layer, i)).to eq 0 } expect(subject.count(layer, 6)).to eq 1