-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PEOPLE: Geschwister in Abteilung als computed value #289
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
b2c9f7d
Implement logic for siblings_in_layer #2147
diegosteiner c2070ce
switch sibling relation from person_relations to family_members
diegosteiner 830cff1
remove column brother_and_sisters from person
diegosteiner 05c3584
add siblings in layer to person details view
diegosteiner 56224d8
move sibling finder logic into separate service
diegosteiner 1e3dff5
add logic and specs for finding siblings in events
diegosteiner 8078514
refactor siblings in context to be more generic
diegosteiner 469b6d2
refactor siblings in context to be more generic
diegosteiner 3998dee
add has_siblings_in_context to json api
diegosteiner 1f2f894
add has_siblings_in_layer to people full export
diegosteiner 04f4e20
add has_siblings_in_event to participations export
diegosteiner 54a81c6
add entry in changelog
diegosteiner 08dffb4
fix failing spec after adding has_siblings_in_event
diegosteiner f3cc868
remove dead code
diegosteiner f5551b2
add correct translations to siblings_in_context
diegosteiner 3e58502
Update app/domain/person/family_member_finder.rb
diegosteiner 16e03cf
Fix indentation
TheWalkingLeek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Copyright (c) 2023, Pfadibewegung Schweiz. This file is part of | ||
# hitobito_pbs and licensed under the Affero General Public License version 3 | ||
# or later. See the COPYING file at the top-level directory or at | ||
# https://github.com/hitobito/hitobito_pbs. | ||
|
||
class Person::FamilyMemberFinder | ||
attr_reader :person | ||
|
||
def initialize(person) | ||
@person = person | ||
end | ||
|
||
def family_members_in_layer(group, kind: :sibling) | ||
Role.joins(person: :family_members) | ||
.where(group: group.groups_in_same_layer, | ||
person: { family_members: { kind: kind, other: person } }) | ||
end | ||
|
||
def family_members_in_event(event, kind: :sibling) | ||
Event::Participation.joins(person: :family_members) | ||
.where(person: { family_members: { kind: kind, other: person } }, | ||
event: event) | ||
end | ||
|
||
def family_members_in_context(context, kind: :sibling) | ||
case context | ||
when Event | ||
family_members_in_event(context, kind: kind) | ||
when Group | ||
family_members_in_layer(context, kind: kind) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
db/migrate/20230912120642_remove_brother_and_sister_from_persons.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class RemoveBrotherAndSisterFromPersons < ActiveRecord::Migration[6.1] | ||
def change | ||
remove_column :people, :brother_and_sisters, :boolean, default: false, null: false | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# encoding: utf-8 | ||
|
||
# Copyright (c) 2017, Pfadibewegung Schweiz. This file is part of | ||
# hitobito_pbs and licensed under the Affero General Public License version 3 | ||
# or later. See the COPYING file at the top-level directory or at | ||
# https://github.com/hitobito/hitobito_pbs. | ||
diegosteiner marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
require 'spec_helper' | ||
|
||
describe Person::FamilyMemberFinder do | ||
|
||
let(:service) { described_class.new(person) } | ||
let(:person) { Fabricate(:person) } | ||
let(:sibling) { Fabricate(:person) } | ||
|
||
let!(:sibling_relation) { Fabricate(:family_member, person: person, other: sibling, kind: :sibling) } | ||
|
||
describe '#family_members_in_event' do | ||
|
||
let(:person_event) { Fabricate(:event) } | ||
let!(:person_participation) { Fabricate(:event_participation, person: person, event: person_event) } | ||
let(:sibling_event) { Fabricate(:event) } | ||
let!(:sibling_participation) { Fabricate(:event_participation, person: sibling, event: sibling_event) } | ||
|
||
subject do | ||
service.family_members_in_event(person_event, kind: :sibling) | ||
end | ||
|
||
context 'without siblings' do | ||
let!(:sibling_relation) { nil } | ||
it { is_expected.to be_empty } | ||
end | ||
|
||
context 'with siblings in different events' do | ||
it { is_expected.to be_empty } | ||
end | ||
|
||
context 'with siblings in same event' do | ||
let(:sibling_event) { person_event } | ||
it { is_expected.to contain_exactly(sibling_participation) } | ||
end | ||
|
||
context 'with siblings with deleted role in same group' do | ||
let!(:sibling_participation) { Fabricate(:event_participation, person: sibling, event: sibling_event, active: false) } | ||
it { is_expected.to be_empty } | ||
end | ||
|
||
end | ||
|
||
describe '#family_members_in_layer' do | ||
|
||
let(:layer) { Fabricate(Group::Abteilung.name) } | ||
|
||
let(:person_group) { Fabricate(Group::Pfadi.name, parent: layer)} | ||
let!(:person_role) { Fabricate(person_group.default_role.name, person: person, group: person_group) } | ||
|
||
let(:sibling_group) { Fabricate(Group::Woelfe.name, parent: layer)} | ||
let!(:sibling_role) { Fabricate(sibling_group.default_role.name, person: sibling, group: sibling_group) } | ||
|
||
subject do | ||
service.family_members_in_layer(person_group, kind: :sibling) | ||
end | ||
|
||
context 'without siblings' do | ||
let!(:sibling_relation) { nil } | ||
it { is_expected.to be_empty } | ||
end | ||
|
||
context 'with siblings in different groups' do | ||
let(:sibling_group) { Fabricate(Group::Woelfe.name, parent: Fabricate(Group::Abteilung.name))} | ||
it { is_expected.to be_empty } | ||
end | ||
|
||
context 'with siblings in same group' do | ||
let(:sibling_group) { person_group } | ||
it { is_expected.to contain_exactly(sibling_role) } | ||
end | ||
|
||
context 'with siblings in same layer' do | ||
it { is_expected.to contain_exactly(sibling_role) } | ||
end | ||
|
||
context 'with siblings with deleted role in same group' do | ||
let!(:sibling_role) do | ||
Fabricate(sibling_group.default_role.name, person: sibling, group: sibling_group, | ||
created_at: 2.months.ago, deleted_at: 1.month.ago) | ||
end | ||
it { is_expected.to be_empty } | ||
end | ||
|
||
end | ||
|
||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ich habe die Logik in einen abgekapselten Service verschoben, weil sie doch an einigen verschiedenen Orten gebraucht wird und so einfacher getestet werden kann.