Skip to content

Commit c0c2eb5

Browse files
committed
map religious_character from GIAS
1 parent 476d48e commit c0c2eb5

13 files changed

Lines changed: 109 additions & 463 deletions

app/models/organisation.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class Organisation < ApplicationRecord
99
has_rich_text :description
1010

1111
SPECIAL_SCHOOL_TYPES = ["Community special school", "Foundation special school", "Non-maintained special school", "Academy special converter", "Academy special sponsor led", "Free schools special"].freeze
12-
NON_FAITH_RELIGIOUS_CHARACTER_TYPES = ["", "None", "Does not apply", "null"].freeze
12+
NON_FAITH_RELIGIOUS_CHARACTER_TYPES = ["None", "Does not apply"].freeze
1313
OUT_OF_SCOPE_DETAILED_SCHOOL_TYPES = ["Further education", "Other independent school", "Miscellaneous", "Special post 16 institution", "Other independent special school", "Higher education institutions", "Welsh establishment"].freeze
1414

1515
friendly_id :slug_candidates, use: %i[slugged history]
@@ -53,7 +53,7 @@ class Organisation < ApplicationRecord
5353

5454
scope :visible_to_jobseekers, -> { schools.not_closed.not_out_of_scope.or(Organisation.trusts).registered_for_service }
5555

56-
scope :only_faith_schools, -> { where.not("gias_data ->> 'ReligiousCharacter (name)' IN (?)", NON_FAITH_RELIGIOUS_CHARACTER_TYPES) }
56+
scope :only_faith_schools, -> { where.not(religious_character: NON_FAITH_RELIGIOUS_CHARACTER_TYPES) }
5757

5858
# This can safely ignore the 'extra' LA mappings as it is always called with a scope which excludes LAs in the first place
5959
scope :with_live_vacancies, lambda {

app/models/school.rb

Lines changed: 58 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,64 @@ class School < Organisation
1212
INDEPENDENT_SCHOOL_TYPE = "Independent schools".freeze
1313
VALID_SCHOOL_TYPES = [LA_SCHOOL_TYPE, INDEPENDENT_SCHOOL_TYPE, "Special schools", "Universities", ACADEMY_TYPE, FREE_SCHOOL_TYPE, "Welsh schools", "Other types", "Colleges", "Online provider"].freeze
1414

15-
# This is direct from GIAS (with plurals removed via singularize)
15+
# This is direct from GIAS
1616
validates :school_type, inclusion: { in: VALID_SCHOOL_TYPES }
1717

18+
CHRISTIAN_RELIGIOUS_TYPES = ["Anglican",
19+
"United Reformed Church",
20+
"Christian",
21+
"Greek Orthodox",
22+
"Anglican/Evangelical",
23+
"Anglican/Church of England",
24+
"Christian/Evangelical",
25+
"Christian/Methodist",
26+
"Christian/non-denominational",
27+
"Protestant/Evangelical",
28+
"Methodist/Church of England",
29+
"Protestant",
30+
"Reformed Baptist",
31+
"Christian Science",
32+
"Church of England",
33+
"Plymouth Brethren Christian Church",
34+
"Church of England/Methodist/United Reform Church/Baptist",
35+
"Moravian", # Protestant Christian church movement
36+
"Quaker",
37+
"Methodist",
38+
"Free Church",
39+
"Church of England/Free Church",
40+
"Church of England/Evangelical",
41+
"Church of England/United Reformed Church",
42+
"Anglican/Christian",
43+
"Inter- / non- denominational",
44+
"Seventh Day Adventist",
45+
"Church of England/Christian",
46+
"Church of England/Methodist",
47+
"Congregational Church"].freeze
48+
49+
CATHOLIC_RELIGIOUS_TYPES = ["Roman Catholic",
50+
"Catholic",
51+
"Roman Catholic/Anglican",
52+
"Roman Catholic/Church of England",
53+
"Church of England/Roman Catholic"].freeze
54+
55+
OTHER_RELIGIOUS_TYPES = [
56+
"Jewish",
57+
"Orthodox Jewish",
58+
"Charadi Jewish",
59+
"Islam",
60+
"Muslim",
61+
"Sunni Deobandi",
62+
"Buddhist",
63+
"Sikh",
64+
"Hindu",
65+
"Multi-faith",
66+
].freeze
67+
68+
validates :religious_character, inclusion: {
69+
in: NON_FAITH_RELIGIOUS_CHARACTER_TYPES + CHRISTIAN_RELIGIOUS_TYPES + CATHOLIC_RELIGIOUS_TYPES + OTHER_RELIGIOUS_TYPES,
70+
allow_nil: false,
71+
}
72+
1873
EXCLUDED_DETAILED_SCHOOL_TYPES = [
1974
"Further education",
2075
"Other independent school",
@@ -51,13 +106,6 @@ class School < Organisation
51106
through: %i[early_years ks1 ks2 ks3 ks4 ks5],
52107
}.freeze
53108

54-
def religious_character
55-
return if !respond_to?(:gias_data) || gias_data.nil?
56-
return if ["None", "Does not apply"].include?(gias_data["ReligiousCharacter (name)"])
57-
58-
gias_data["ReligiousCharacter (name)"]
59-
end
60-
61109
def live_group_vacancies
62110
if part_of_a_trust?
63111
org_ids = [trust.id] + trust.schools.pluck(:id)
@@ -71,11 +119,11 @@ def live_group_vacancies
71119
end
72120

73121
def faith_school?
74-
religious_character.present?
122+
NON_FAITH_RELIGIOUS_CHARACTER_TYPES.exclude? religious_character
75123
end
76124

77125
def catholic_school?
78-
religious_character&.include?("Catholic") || false
126+
religious_character.in? CATHOLIC_RELIGIOUS_TYPES
79127
end
80128

81129
def key_stages

app/services/search/school_search.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,12 @@ def apply_school_type_filter(scope)
108108
return scope unless school_types.present?
109109

110110
if school_types.include?("special_school") && school_types.include?("faith_school")
111-
scope.where.not("gias_data ->> 'ReligiousCharacter (name)' IN (?)", Organisation::NON_FAITH_RELIGIOUS_CHARACTER_TYPES)
111+
scope.where.not(religious_character: Organisation::NON_FAITH_RELIGIOUS_CHARACTER_TYPES)
112112
.or(scope.where(detailed_school_type: Organisation::SPECIAL_SCHOOL_TYPES))
113113
elsif school_types.include?("special_school")
114114
scope.where(detailed_school_type: Organisation::SPECIAL_SCHOOL_TYPES)
115115
elsif school_types.include?("faith_school")
116-
scope.where.not("gias_data ->> 'ReligiousCharacter (name)' IN (?)", Organisation::NON_FAITH_RELIGIOUS_CHARACTER_TYPES)
116+
scope.where.not(religious_character: Organisation::NON_FAITH_RELIGIOUS_CHARACTER_TYPES)
117117
else
118118
scope
119119
end

spec/factories/schools.rb

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"TypeOfEstablishment (code)": "02",
2727
}
2828
end
29+
religious_character { "None" }
2930
detailed_school_type { "Voluntary aided school" }
3031
minimum_age { 11 }
3132
maximum_age { 18 }
@@ -74,22 +75,7 @@
7475
end
7576

7677
trait :catholic do
77-
gias_data do
78-
{
79-
CloseDate: nil,
80-
HeadFirstName: Faker::Name.first_name,
81-
HeadLastName: Faker::Name.last_name.delete("'"),
82-
HeadPreferredJobTitle: Faker::Name.prefix.delete("."),
83-
DateOfLastInspectionVisit: Faker::Date.between(from: 999.days.ago, to: 5.days.ago),
84-
NumberOfPupils: Faker::Number.number(digits: 3),
85-
"OfstedRating (name)": factory_sample(ofsted_ratings),
86-
OpenDate: Faker::Date.between(from: 10_000.days.ago, to: 1000.days.ago),
87-
"ReligiousCharacter (name)": "Roman Catholic",
88-
SchoolCapacity: Faker::Number.number(digits: 4),
89-
TelephoneNum: Faker::Number.number(digits: 11).to_s,
90-
"Trusts (name)": "#{Faker::Company.name.delete("'")} Trust",
91-
}
92-
end
78+
religious_character { "Roman Catholic" }
9379
end
9480

9581
trait :no_geolocation do

0 commit comments

Comments
 (0)