Browse Source

Put db enums in one folder and add a few new field changes"

pull/79/head
Kat 4 years ago
parent
commit
c746e669eb
  1. 14
      app/constants/benefit_cap.rb
  2. 143
      app/constants/db_enums.rb
  3. 19
      app/constants/ecstat.rb
  4. 27
      app/constants/ethnic.rb
  5. 11
      app/constants/homeless.rb
  6. 24
      app/constants/national.rb
  7. 31
      app/constants/previous_tenancy.rb
  8. 39
      app/models/case_log.rb
  9. 2
      config/forms/2021_2022.json
  10. 8
      db/migrate/20211103090530_change_field_types.rb
  11. 10
      db/schema.rb

14
app/constants/benefit_cap.rb

@ -1,14 +0,0 @@
module BenefitCap
@@benefitcap = {
"Yes - benefit cap" => 5,
"Yes - removal of the spare room subsidy" => 4,
"Yes - both the benefit cap and the removal of the spare room subsidy" => 6,
"No" => 2,
"Do not know" => 3,
"Prefer not to say" => 100,
}
def self.benefitcap
@@benefitcap
end
end

143
app/constants/db_enums.rb

@ -0,0 +1,143 @@
module DbEnums
def self.benefitcap
{
"Yes - benefit cap" => 5,
"Yes - removal of the spare room subsidy" => 4,
"Yes - both the benefit cap and the removal of the spare room subsidy" => 6,
"No" => 2,
"Do not know" => 3,
"Prefer not to say" => 100,
}
end
def self.ecstat
{
"Part-time - Less than 30 hours" => 2,
"Full-time - 30 hours or more" => 1,
"In government training into work, such as New Deal" => 3,
"Jobseeker" => 4,
"Retired" => 5,
"Not seeking work" => 6,
"Full-time student" => 7,
"Unable to work because of long term sick or disability" => 8,
"Child under 16" => 100,
"Other" => 0,
"Prefer not to say" => 10,
}
end
def self.ethnic
{
"White: English/Scottish/Welsh/Northern Irish/British" => 1,
"White: Irish" => 2,
"White: Gypsy/Irish Traveller" => 18,
"White: Other" => 3,
"Mixed: White & Black Caribbean" => 4,
"Mixed: White & Black African" => 5,
"Mixed: White & Asian" => 6,
"Mixed: Other" => 7,
"Asian or Asian British: Indian" => 8,
"Asian or Asian British: Pakistani" => 9,
"Asian or Asian British: Bangladeshi" => 10,
"Asian or Asian British: Chinese" => 15,
"Asian or Asian British: Other" => 11,
"Black: Caribbean" => 12,
"Black: African" => 13,
"Black: Other" => 14,
"Other Ethnic Group: Arab" => 16,
"Other Ethnic Group: Other" => 19,
"Prefer not to say" => 17,
}
end
def self.homeless
{
"Yes - assessed as homeless by a local authority and owed a homelessness duty. Including if threatened with homelessness within 56 days" => 11,
"Yes - other homelessness" => 7,
"No" => 1,
}
end
def self.illness
{
"Yes" => 1,
"No" => 2,
"Do not know" => 3,
"Prefer not to say" => 100,
}
end
def self.leftreg
{
"Yes" => 6,
"No - they left up to 5 years ago" => 4,
"No - they left more than 5 years ago" => 5,
"Prefer not to say" => 3,
}
end
def self.national
{
"UK national resident in UK" => 1,
"A current or former reserve in the UK Armed Forces (exc. National Service)" => 100,
"UK national returning from residence overseas" => 2,
"Czech Republic" => 3,
"Estonia" => 4,
"Hungary" => 5,
"Latvia" => 6,
"Lithuania" => 7,
"Poland" => 8,
"Slovakia" => 9,
"Bulgaria" => 14,
"Romania" => 15,
"Ireland" => 17,
"Other EU Economic Area (EEA country)" => 11,
"Any other country" => 12,
"Prefer not to say" => 13,
}
end
def self.pregnancy
{
"Yes" => 1,
"No" => 2,
"Prefer not to say" => 3,
}
end
def self.previous_tenancy
{
"Owner occupation (private) " => 26,
"Owner occupation (low cost home ownership)" => 27,
"Private sector tenancy" => 3,
"Tied housing or rented with job" => 4,
"Supported housing" => 5,
"Sheltered accomodation" => 8,
"Residential care home" => 9,
"Living with friends or family" => 28,
"Refuge" => 21,
"Hospital" => 10,
"Prison / approved probation hostel" => 29,
"Direct access hostel" => 7,
"Bed & Breakfast" => 14,
"Mobile home / caravan" => 23,
"Any other temporary accommodation" => 18,
"Home Office Asylum Support" => 24,
"Children’s home / foster care" => 13,
"Rough sleeping" => 19,
"Other" => 25,
"Fixed term Local Authority General Needs tenancy" => 30,
"Lifetime Local Authority General Needs tenancy" => 31,
"Fixed term PRP General Needs tenancy" => 32,
"Lifetime PRP General Needs tenancy" => 33,
}
end
def self.reservist
{
"Yes" => 1,
"No" => 2,
"Prefer not to say" => 3,
}
end
end

19
app/constants/ecstat.rb

@ -1,19 +0,0 @@
module Ecstat
@@ecstat = {
"Part-time - Less than 30 hours" => 2,
"Full-time - 30 hours or more" => 1,
"In government training into work, such as New Deal" => 3,
"Jobseeker" => 4,
"Retired" => 5,
"Not seeking work" => 6,
"Full-time student" => 7,
"Unable to work because of long term sick or disability" => 8,
"Child under 16" => 100,
"Other" => 0,
"Prefer not to say" => 10,
}
def self.ecstat
@@ecstat
end
end

27
app/constants/ethnic.rb

@ -1,27 +0,0 @@
module Ethnic
@@ethnic = {
"White: English/Scottish/Welsh/Northern Irish/British" => 1,
"White: Irish" => 2,
"White: Gypsy/Irish Traveller" => 18,
"White: Other" => 3,
"Mixed: White & Black Caribbean" => 4,
"Mixed: White & Black African" => 5,
"Mixed: White & Asian" => 6,
"Mixed: Other" => 7,
"Asian or Asian British: Indian" => 8,
"Asian or Asian British: Pakistani" => 9,
"Asian or Asian British: Bangladeshi" => 10,
"Asian or Asian British: Chinese" => 15,
"Asian or Asian British: Other" => 11,
"Black: Caribbean" => 12,
"Black: African" => 13,
"Black: Other" => 14,
"Other Ethnic Group: Arab" => 16,
"Other Ethnic Group: Other" => 19,
"Prefer not to say" => 17,
}
def self.ethnic
@@ethnic
end
end

11
app/constants/homeless.rb

@ -1,11 +0,0 @@
module Homeless
@@homeless = {
"Yes - assessed as homeless by a local authority and owed a homelessness duty. Including if threatened with homelessness within 56 days" => 11,
"Yes - other homelessness" => 7,
"No" => 1,
}
def self.homeless
@@homeless
end
end

24
app/constants/national.rb

@ -1,24 +0,0 @@
module National
@@national = {
"UK national resident in UK" => 1,
"A current or former reserve in the UK Armed Forces (exc. National Service)" => 100,
"UK national returning from residence overseas" => 2,
"Czech Republic" => 3,
"Estonia" => 4,
"Hungary" => 5,
"Latvia" => 6,
"Lithuania" => 7,
"Poland" => 8,
"Slovakia" => 9,
"Bulgaria" => 14,
"Romania" => 15,
"Ireland" => 17,
"Other EU Economic Area (EEA country)" => 11,
"Any other country" => 12,
"Prefer not to say" => 13,
}
def self.national
@@national
end
end

31
app/constants/previous_tenancy.rb

@ -1,31 +0,0 @@
module PreviousTenancy
@@previous_tenancy = {
"Owner occupation (private) " => 26,
"Owner occupation (low cost home ownership)" => 27,
"Private sector tenancy" => 3,
"Tied housing or rented with job" => 4,
"Supported housing" => 5,
"Sheltered accomodation" => 8,
"Residential care home" => 9,
"Living with friends or family" => 28,
"Refuge" => 21,
"Hospital" => 10,
"Prison / approved probation hostel" => 29,
"Direct access hostel" => 7,
"Bed & Breakfast" => 14,
"Mobile home / caravan" => 23,
"Any other temporary accommodation" => 18,
"Home Office Asylum Support" => 24,
"Children’s home / foster care" => 13,
"Rough sleeping" => 19,
"Other" => 25,
"Fixed term Local Authority General Needs tenancy" => 30,
"Lifetime Local Authority General Needs tenancy" => 31,
"Fixed term PRP General Needs tenancy" => 32,
"Lifetime PRP General Needs tenancy" => 33,
}
def self.previous_tenancy
@@previous_tenancy
end
end

39
app/models/case_log.rb

@ -36,13 +36,8 @@ end
class CaseLog < ApplicationRecord
include Discard::Model
include SoftValidations
include Ethnic
include National
include Ecstat
include PreviousTenancy
include Homeless
include BenefitCap
include SoftValidations
include DbEnums
default_scope -> { kept }
scope :not_completed, -> { where.not(status: "completed") }
@ -53,19 +48,23 @@ class CaseLog < ApplicationRecord
enum status: { "not_started" => 0, "in_progress" => 1, "completed" => 2 }
enum ethnic: Ethnic.ethnic
enum national: National.national, _suffix: true
enum ecstat1: Ecstat.ecstat, _suffix: true
enum ecstat2: Ecstat.ecstat, _suffix: true
enum ecstat3: Ecstat.ecstat, _suffix: true
enum ecstat4: Ecstat.ecstat, _suffix: true
enum ecstat5: Ecstat.ecstat, _suffix: true
enum ecstat6: Ecstat.ecstat, _suffix: true
enum ecstat7: Ecstat.ecstat, _suffix: true
enum ecstat8: Ecstat.ecstat, _suffix: true
enum prevten: PreviousTenancy.previous_tenancy, _suffix: true
enum homeless: Homeless.homeless, _suffix: true
enum underoccupation_benefitcap: BenefitCap.benefitcap, _suffix: true
enum ethnic: DbEnums.ethnic
enum national: DbEnums.national, _suffix: true
enum ecstat1: DbEnums.ecstat, _suffix: true
enum ecstat2: DbEnums.ecstat, _suffix: true
enum ecstat3: DbEnums.ecstat, _suffix: true
enum ecstat4: DbEnums.ecstat, _suffix: true
enum ecstat5: DbEnums.ecstat, _suffix: true
enum ecstat6: DbEnums.ecstat, _suffix: true
enum ecstat7: DbEnums.ecstat, _suffix: true
enum ecstat8: DbEnums.ecstat, _suffix: true
enum prevten: DbEnums.previous_tenancy, _suffix: true
enum homeless: DbEnums.homeless, _suffix: true
enum underoccupation_benefitcap: DbEnums.benefitcap, _suffix: true
enum reservist: DbEnums.reservist, _suffix: true
enum leftreg: DbEnums.leftreg, _suffix: true
enum illness: DbEnums.illness, _suffix: true
enum preg_occ: DbEnums.pregnancy, _suffix: true
AUTOGENERATED_FIELDS = %w[id status created_at updated_at discarded_at].freeze

2
config/forms/2021_2022.json

@ -742,7 +742,7 @@
"header": "",
"description": "",
"questions": {
"ILLNESS": {
"illness": {
"header": "Does anyone in the household have any of the following that they expect to last for 12 months or more:<ul><li>Physical Condition</li><li>Mental Health Condition</li><li>Other Illness</li></ul>",
"hint_text": "",
"type": "radio",

8
db/migrate/20211103090530_change_field_types.rb

@ -14,6 +14,10 @@ class ChangeFieldTypes < ActiveRecord::Migration[6.1]
t.change :prevten, "integer USING prevten::integer"
t.change :homeless, "integer USING homeless::integer"
t.change :underoccupation_benefitcap, "integer USING underoccupation_benefitcap::integer"
t.change :reservist, "integer USING reservist::integer"
t.change :leftreg, "integer USING leftreg::integer"
t.change :illness, "integer USING illness::integer"
t.change :preg_occ, "integer USING preg_occ::integer"
end
end
@ -32,6 +36,10 @@ class ChangeFieldTypes < ActiveRecord::Migration[6.1]
t.change :prevten, :string
t.change :homeless, :string
t.change :underoccupation_benefitcap, :string
t.change :reservist, :string
t.change :leftreg, :string
t.change :illness, :string
t.change :preg_occ, :string
end
end
end

10
db/schema.rb

@ -58,12 +58,12 @@ ActiveRecord::Schema.define(version: 2021_11_03_090530) do
t.integer "ecstat8"
t.integer "homeless"
t.string "reason_for_leaving_last_settled_home"
t.string "underoccupation_benefitcap"
t.string "leftreg"
t.string "reservist"
t.integer "underoccupation_benefitcap"
t.integer "leftreg"
t.integer "reservist"
t.string "armed_forces_partner"
t.string "illness"
t.string "preg_occ"
t.integer "illness"
t.integer "preg_occ"
t.string "accessibility_requirements"
t.string "condition_effects"
t.string "tenancy_code"

Loading…
Cancel
Save