From 237e7e33bfc447ce605a4057527951d9d1fc7c56 Mon Sep 17 00:00:00 2001 From: Carlo Beltrame Date: Mon, 23 Aug 2021 19:07:42 +0200 Subject: [PATCH] Stop exposing abteilungen via the specialized group health API --- app/controllers/group_health_controller.rb | 15 +-------------- spec/controllers/group_health_controller_spec.rb | 7 ------- 2 files changed, 1 insertion(+), 21 deletions(-) diff --git a/app/controllers/group_health_controller.rb b/app/controllers/group_health_controller.rb index 56f50f099..8bb5888b6 100644 --- a/app/controllers/group_health_controller.rb +++ b/app/controllers/group_health_controller.rb @@ -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 @@ -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)) @@ -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}") diff --git a/spec/controllers/group_health_controller_spec.rb b/spec/controllers/group_health_controller_spec.rb index 81fae3c6c..62f07a0d6 100644 --- a/spec/controllers/group_health_controller_spec.rb +++ b/spec/controllers/group_health_controller_spec.rb @@ -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)