import religious character from GIAS and correct mapping #8751
Conversation
2b92fe8 to
3923ab8
Compare
af06be8 to
2a658be
Compare
3923ab8 to
9fc0f94
Compare
dbe3838 to
32540fd
Compare
9fc0f94 to
93f60fe
Compare
32540fd to
8f0a6d0
Compare
|
Review app https://teaching-vacancies-review-pr-8751.test.teacherservices.cloud was successfully deleted |
8f0a6d0 to
8ee4570
Compare
8ee4570 to
5772b6d
Compare
5772b6d to
f6b3d75
Compare
f6b3d75 to
f22e975
Compare
f22e975 to
46acfd0
Compare
There was a problem hiding this comment.
Pull request overview
This PR moves religious character (and a few other GIAS-derived fields) out of the gias_data JSON and into first-class organisations columns, then updates filtering and import logic to use those columns.
Changes:
- Add new
organisationscolumns (religious_character,number_of_pupils,school_capacity,trust_school_flag_code,trusts_code) and populate them via the GIAS schools import. - Update faith/special-school filtering and SAT sign-in school lookup to query the new columns instead of
gias_data. - Remove/stop using
gias_data/gias_data_hashacross code/tests/fixtures, including removing the hash refresh job from the schedule.
Reviewed changes
Copilot reviewed 30 out of 30 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| spec/system/publishers/publishers_can_filter_vacancies_in_their_dashboard_spec.rb | Updates school factory setup to use school_type instead of gias_data. |
| spec/system/jobseekers/jobseekers_can_search_for_schools_spec.rb | Updates faith/non-faith setup to use religious_character column. |
| spec/system/jobseekers/jobseekers_can_search_for_jobs_spec.rb | Updates faith/non-faith setup to use religious_character column. |
| spec/services/search/school_search_spec.rb | Updates school search specs to use religious_character column. |
| spec/services/gias/import_trusts_spec.rb | Removes expectations around storing trust gias_data. |
| spec/services/gias/import_schools_and_local_authorities_spec.rb | Updates stubbed GIAS CSV headers/rows to include new fields; removes gias_data assertions. |
| spec/queries/vacancy_filter_query_spec.rb | Updates vacancy filtering specs to use religious_character column. |
| spec/presenters/vacancy_decorator_spec.rb | Updates decorator spec to build schools with religious_character column. |
| spec/models/school_spec.rb | Removes School#religious_character JSON-based behaviour tests; updates catholic/variant tests. |
| spec/models/school_group_spec.rb | Removes assertions that SchoolGroup has a gias_data JSON column. |
| spec/models/organisation_spec.rb | Removes refresh_gias_data_hash behaviour specs. |
| spec/fixtures/st_albans_schools.yml | Removes embedded gias_data/hash from fixtures; adds religious_character. |
| spec/fixtures/liverpool_schools.yml | Removes embedded gias_data/hash from fixtures; adds religious_character. |
| spec/fixtures/basildon_schools.yml | Removes embedded gias_data/hash from fixtures; adds religious_character. |
| spec/factories/schools.rb | Replaces gias_data defaults/traits with scalar columns (pupils/capacity/religious_character). |
| spec/factories/school_groups.rb | Removes gias_data factory attribute for school groups. |
| db/schema.rb | Reflects new scalar columns added to organisations. |
| db/migrate/20260423141519_add_religious_character_to_school.rb | Adds new scalar columns onto organisations. |
| config/schedule.yml | Removes scheduled RefreshOrganisationsGiasDataHashJob. |
| config/analytics.yml | Removes gias_data from analytics export allow-list. |
| config/analytics_blocklist.yml | Blocklists the new scalar columns in analytics. |
| app/views/publishers/organisations/_organisation.html.slim | Switches “size” display logic to use number_of_pupils column presence. |
| app/services/search/school_search.rb | Updates faith-school filter to query religious_character column. |
| app/services/gias/import_trusts.rb | Stops persisting gias_data for trusts. |
| app/services/gias/import_schools_and_local_authorities.rb | Maps new GIAS CSV fields into scalar columns (religious character, pupil count, capacity, trust codes). |
| app/models/school.rb | Removes JSON-derived religious_character method; adds religious character type lists + validation; updates faith/catholic logic. |
| app/models/organisation.rb | Updates NON_FAITH types, changes only_faith_schools scope to use column, and ignores gias_data columns. |
| app/jobs/refresh_organisations_gias_data_hash_job.rb | Deletes the job that recomputed gias_data_hash. |
| app/helpers/organisations_helper.rb | Switches school size helpers to use scalar columns; adds :nocov: markers. |
| app/controllers/omniauth_callbacks_controller.rb | Updates SAT contained-school lookup to use trust_school_flag_code/trusts_code columns. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def apply_school_type_filter(scope) | ||
| return scope unless school_types.present? | ||
|
|
||
| if school_types.include?("special_school") && school_types.include?("faith_school") | ||
| scope.where.not("gias_data ->> 'ReligiousCharacter (name)' IN (?)", Organisation::NON_FAITH_RELIGIOUS_CHARACTER_TYPES) | ||
| scope.where.not(religious_character: Organisation::NON_FAITH_RELIGIOUS_CHARACTER_TYPES) | ||
| .or(scope.where(detailed_school_type: Organisation::SPECIAL_SCHOOL_TYPES)) | ||
| elsif school_types.include?("special_school") | ||
| scope.where(detailed_school_type: Organisation::SPECIAL_SCHOOL_TYPES) | ||
| elsif school_types.include?("faith_school") | ||
| scope.where.not("gias_data ->> 'ReligiousCharacter (name)' IN (?)", Organisation::NON_FAITH_RELIGIOUS_CHARACTER_TYPES) | ||
| scope.where.not(religious_character: Organisation::NON_FAITH_RELIGIOUS_CHARACTER_TYPES) | ||
| else |
There was a problem hiding this comment.
default in table is now 'None'
| trust_school_flag_code: 5, # "Supported by a single-academy trust" | ||
| trusts_code: uid, | ||
| ) | ||
|
|
| def change | ||
| add_column :organisations, :religious_character, :string | ||
| add_column :organisations, :number_of_pupils, :integer | ||
| add_column :organisations, :school_capacity, :integer | ||
| add_column :organisations, :trust_school_flag_code, :integer | ||
| add_column :organisations, :trusts_code, :integer | ||
| end |
There was a problem hiding this comment.
Do we need to add a backfill task to populate the religious_character field? Otherwise it looks like all schools, including faith schools, will have it set to "None" and the vacancy filtering for faith schools will be broken until the import is run again at 10PM (I think)
| @@ -81,6 +81,8 @@ class Organisation < ApplicationRecord | |||
| through: 7, | |||
| } | |||
|
|
|||
| self.ignored_columns += %i[gias_data gias_data_hash] | |||
|
|
|||
There was a problem hiding this comment.
Nah, this is our common approach to two-step DB fields removal. Bad copilot.
| - religious_character | ||
| - number_of_pupils | ||
| - trust_school_flag_code | ||
| - trusts_code | ||
| - school_capacity |
There was a problem hiding this comment.
🙋♂️ I suspect the only reason gias_data_hash was blocked from being sent to analytics was to avoid duplication of this computed field vs the raw gias_data JSON being sent already to Analytics.
As we are now removing both gias_data and gias_data_hash, I would assume these new fields should be included in the analytics.yml rather than blocked.
(And this is going to be one we need to catch up on with our Perf. Analyst!)
| # New GIAS team now have some data dictionary information available at | ||
| # https://dfedigital.atlassian.net/wiki/spaces/GTP/pages/6155337742/Data+Dictionary | ||
| # but it's not quite complete/definitive | ||
| # (e.g establishment status says open/closed/proposed when reality is 'open proposed to close' and 'proposed to open') |
| validates :email, email_address: true, if: -> { email_changed? } # Allows data created prior to validation to still be valid | ||
|
|
||
| alias_attribute :data, :gias_data | ||
| # alias_attribute :data, :gias_data |
There was a problem hiding this comment.
| # alias_attribute :data, :gias_data |
39c05ac to
40d3baa
Compare
1284f02 to
20fce7f
Compare
40d3baa to
999b3a3
Compare
3015cbd to
476d48e
Compare
999b3a3 to
c0c2eb5
Compare
476d48e to
d16f0a5
Compare
c0c2eb5 to
b6af1f3
Compare
Trello card URL
https://trello.com/c/wzqdp28P/2820-incorrect-mapping-of-religious-character-schools-for-both-cofe-and-roman-catholic-schools
Changes in this PR:
Map religious character from GIAS, and then filter correctly by the field in the DB.
Remove gias_data and gias_data_hash from database