Skip to content

Commit

Permalink
Update seeds to avoid extra call to database
Browse files Browse the repository at this point in the history
This moves where we set subject limited in the seeds to use the existing
list of hashes rather than an additional call to the database.
  • Loading branch information
thomasleese committed Sep 27, 2023
1 parent ccffe53 commit aad9eed
Showing 1 changed file with 44 additions and 28 deletions.
72 changes: 44 additions & 28 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -240,31 +240,51 @@
"PT" => [{ status_check: "written", sanction_check: "written" }],
"DK" => [{ status_check: "written" }],
"FI" => [{ status_check: "written" }],
"GH" => [
{
requires_preliminary_check: true,
status_check: "online",
sanction_check: "online",
},
],
"GH" => {
subject_limited: true,
regions: [
{
requires_preliminary_check: true,
status_check: "online",
sanction_check: "online",
},
],
},
"HK" => [{ status_check: "written", sanction_check: "written" }],
"IN" => [],
"JM" => [{ status_check: "written", sanction_check: "written" }],
"NG" => [
{
requires_preliminary_check: true,
status_check: "written",
sanction_check: "written",
teaching_authority_provides_written_statement: true,
teaching_authority_name:
"Teachers Registration Council of Nigeria (TRCN)",
teaching_authority_certificate: "Letter of Professional Standing",
},
],
"SG" => [{ status_check: "online" }],
"ZA" => [{ status_check: "written", sanction_check: "written" }],
"IN" => {
subject_limited: true,
},
"JM" => {
subject_limited: true,
regions: [{ status_check: "written", sanction_check: "written" }],
},
"NG" => {
subject_limited: true,
regions: [
{
requires_preliminary_check: true,
status_check: "written",
sanction_check: "written",
teaching_authority_provides_written_statement: true,
teaching_authority_name:
"Teachers Registration Council of Nigeria (TRCN)",
teaching_authority_certificate: "Letter of Professional Standing",
},
],
},
"SG" => {
subject_limited: true,
regions: [{ status_check: "online" }],
},
"ZA" => {
subject_limited: true,
regions: [{ status_check: "written", sanction_check: "written" }],
},
"UA" => [{ reduced_evidence_accepted: true }],
"ZW" => [{ status_check: "written" }],
"ZW" => {
subject_limited: true,
regions: [{ status_check: "written" }],
},
"GG" => [],
"JE" => [],
}.freeze
Expand All @@ -274,7 +294,7 @@
DEFAULT_REGION = { name: "" }.freeze

COUNTRIES.each do |code, value|
regions = value.is_a?(Hash) ? value[:regions] : value
regions = value.is_a?(Hash) ? value.fetch(:regions, []) : value
country_hash = value.is_a?(Hash) ? value.except(:regions) : {}

country =
Expand Down Expand Up @@ -369,7 +389,3 @@
name: english_language_provider[:name],
).update!(english_language_provider.except(:name))
end

subject_limited_countries = %w[GH IN JM NG SG ZA ZW]

Country.where(code: subject_limited_countries).update_all(subject_limited: true)

0 comments on commit aad9eed

Please sign in to comment.