Skip to content

Commit

Permalink
Stop exposing abteilungen via the specialized group health API
Browse files Browse the repository at this point in the history
  • Loading branch information
carlobeltrame committed Aug 23, 2021
1 parent 941e542 commit 237e7e3
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 21 deletions.
15 changes: 1 addition & 14 deletions app/controllers/group_health_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ class GroupHealthController < ApplicationController
GROUP_HEALTH_JOIN = "INNER JOIN #{Group.quoted_table_name} AS layer " \
"ON #{Group.quoted_table_name}.layer_group_id = layer.id " \
'AND layer.group_health = TRUE'.freeze
# query the group of type "Kantonalverband" which lies above in the hierarchical structure
CANTON_JOIN = "LEFT JOIN #{Group.quoted_table_name} AS canton " \
"ON #{Group.quoted_table_name}.lft >= canton.lft " \
"AND #{Group.quoted_table_name}.lft < canton.rgt " \
'AND canton.type = "Group::Kantonalverband"'.freeze
DEFAULT_PAGE_SIZE = 20.freeze

before_action do
Expand Down Expand Up @@ -65,7 +60,7 @@ def roles
end

def groups
respond(Group.from("((#{bund}) UNION (#{cantons}) UNION (#{abt_and_below})) " \
respond(Group.from("((#{bund}) UNION (#{cantons})) " \
"AS #{Group.quoted_table_name}")
.page(params[:page]).per(params[:size] || DEFAULT_PAGE_SIZE)
.as_json(only: GROUPS_FIELDS))
Expand Down Expand Up @@ -193,14 +188,6 @@ def cantons
.to_sql
end

def abt_and_below
Group.select("#{Group.quoted_table_name}.*", 'canton.id as canton_id',
'canton.name as canton_name')
.joins(CANTON_JOIN)
.joins(GROUP_HEALTH_JOIN).distinct
.to_sql
end

def set_j_s_kind(camp)
j_s_kind = camp['j_s_kind'].presence || 'none'
camp.merge(j_s_kind: "j_s_kind_#{j_s_kind}")
Expand Down
7 changes: 0 additions & 7 deletions spec/controllers/group_health_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,6 @@
groups(:schekka).update(group_health: true)
end

it 'does export the group having opted in' do
get :groups, format: :json
json = JSON.parse(response.body)
groups = json['groups'].select {|g| g['name'] == groups(:schekka).name}
expect(groups.size).to eq(1)
end

it 'does only export people with roles in a group having opted in' do
get :people, format: :json
json = JSON.parse(response.body)
Expand Down

0 comments on commit 237e7e3

Please sign in to comment.