Browse Source

change ecstat column types

pull/79/head
Kat 4 years ago
parent
commit
f11ecb3da8
  1. 19
      app/constants/ecstat.rb
  2. 2
      app/controllers/case_logs_controller.rb
  3. 9
      app/models/case_log.rb
  4. 4
      app/views/layouts/application.html.erb
  5. 144
      config/forms/2021_2022.json
  6. 16
      db/migrate/20211103090530_change_field_types.rb
  7. 20
      db/schema.rb

19
app/constants/ecstat.rb

@ -0,0 +1,19 @@
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

2
app/controllers/case_logs_controller.rb

@ -121,7 +121,7 @@ private
end end
def authenticate def authenticate
http_basic_authenticate_or_request_with ethnic: ENV["API_USER"], password: ENV["API_KEY"] http_basic_authenticate_or_request_with name: ENV["API_USER"], password: ENV["API_KEY"]
end end
def api_case_log_params def api_case_log_params

9
app/models/case_log.rb

@ -39,6 +39,7 @@ class CaseLog < ApplicationRecord
include SoftValidations include SoftValidations
include Ethnic include Ethnic
include National include National
include Ecstat
default_scope -> { kept } default_scope -> { kept }
scope :not_completed, -> { where.not(status: "completed") } scope :not_completed, -> { where.not(status: "completed") }
@ -51,6 +52,14 @@ class CaseLog < ApplicationRecord
enum ethnic: Ethnic.ethnic enum ethnic: Ethnic.ethnic
enum national: National.national, _suffix: true 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
AUTOGENERATED_FIELDS = %w[id status created_at updated_at discarded_at].freeze AUTOGENERATED_FIELDS = %w[id status created_at updated_at discarded_at].freeze

4
app/views/layouts/application.html.erb

@ -4,9 +4,9 @@
<title>DLUHC CORE Data Collection</title> <title>DLUHC CORE Data Collection</title>
<%= csrf_meta_tags %> <%= csrf_meta_tags %>
<%= csp_meta_tag %> <%= csp_meta_tag %>
<%= tag :meta, ethnic: 'viewport', content: 'width=device-width, initial-scale=1' %> <%= tag :meta, name: 'viewport', content: 'width=device-width, initial-scale=1' %>
<%= tag :meta, property: 'og:image', content: asset_pack_path('media/images/govuk-opengraph-image.png') %> <%= tag :meta, property: 'og:image', content: asset_pack_path('media/images/govuk-opengraph-image.png') %>
<%= tag :meta, ethnic: 'theme-color', content: '#0b0c0c' %> <%= tag :meta, name: 'theme-color', content: '#0b0c0c' %>
<%= favicon_link_tag asset_pack_path('media/images/favicon.ico') %> <%= favicon_link_tag asset_pack_path('media/images/favicon.ico') %>
<%= favicon_link_tag asset_pack_path('media/images/govuk-mask-icon.svg'), rel: 'mask-icon', type: 'image/svg', color: "#0b0c0c" %> <%= favicon_link_tag asset_pack_path('media/images/govuk-mask-icon.svg'), rel: 'mask-icon', type: 'image/svg', color: "#0b0c0c" %>
<%= favicon_link_tag asset_pack_path('media/images/govuk-apple-touch-icon.png'), rel: 'apple-touch-icon', type: 'image/png' %> <%= favicon_link_tag asset_pack_path('media/images/govuk-apple-touch-icon.png'), rel: 'apple-touch-icon', type: 'image/png' %>

144
config/forms/2021_2022.json

@ -127,16 +127,16 @@
"hint_text": "", "hint_text": "",
"type": "radio", "type": "radio",
"answer_options": { "answer_options": {
"0": "Part-time - Less than 30 hours", "2": "Part-time - Less than 30 hours",
"1": "Full-time - 30 hours or more", "1": "Full-time - 30 hours or more",
"2": "In government training into work, such as New Deal", "3": "In government training into work, such as New Deal",
"3": "Jobseeker", "4": "Jobseeker",
"4": "Retired", "5": "Retired",
"5": "Not seeking work", "6": "Not seeking work",
"6": "Full-time student", "7": "Full-time student",
"7": "Unable to work because of long term sick or disability", "8": "Unable to work because of long term sick or disability",
"8": "Child under 16", "100": "Child under 16",
"9": "Other", "0": "Other",
"10": "Prefer not to say" "10": "Prefer not to say"
} }
} }
@ -224,16 +224,16 @@
"hint_text": "", "hint_text": "",
"type": "radio", "type": "radio",
"answer_options": { "answer_options": {
"0": "Part-time - Less than 30 hours", "2": "Part-time - Less than 30 hours",
"1": "Full-time - 30 hours or more", "1": "Full-time - 30 hours or more",
"2": "In government training into work, such as New Deal", "3": "In government training into work, such as New Deal",
"3": "Jobseeker", "4": "Jobseeker",
"4": "Retired", "5": "Retired",
"5": "Not seeking work", "6": "Not seeking work",
"6": "Full-time student", "7": "Full-time student",
"7": "Unable to work because of long term sick or disability", "8": "Unable to work because of long term sick or disability",
"8": "Child under 16", "100": "Child under 16",
"9": "Other", "0": "Other",
"10": "Prefer not to say" "10": "Prefer not to say"
} }
}, },
@ -276,16 +276,16 @@
"hint_text": "", "hint_text": "",
"type": "radio", "type": "radio",
"answer_options": { "answer_options": {
"0": "Part-time - Less than 30 hours", "2": "Part-time - Less than 30 hours",
"1": "Full-time - 30 hours or more", "1": "Full-time - 30 hours or more",
"2": "In government training into work, such as New Deal", "3": "In government training into work, such as New Deal",
"3": "Jobseeker", "4": "Jobseeker",
"4": "Retired", "5": "Retired",
"5": "Not seeking work", "6": "Not seeking work",
"6": "Full-time student", "7": "Full-time student",
"7": "Unable to work because of long term sick or disability", "8": "Unable to work because of long term sick or disability",
"8": "Child under 16", "100": "Child under 16",
"9": "Other", "0": "Other",
"10": "Prefer not to say" "10": "Prefer not to say"
} }
}, },
@ -328,16 +328,16 @@
"hint_text": "", "hint_text": "",
"type": "radio", "type": "radio",
"answer_options": { "answer_options": {
"0": "Part-time - Less than 30 hours", "2": "Part-time - Less than 30 hours",
"1": "Full-time - 30 hours or more", "1": "Full-time - 30 hours or more",
"2": "In government training into work, such as New Deal", "3": "In government training into work, such as New Deal",
"3": "Jobseeker", "4": "Jobseeker",
"4": "Retired", "5": "Retired",
"5": "Not seeking work", "6": "Not seeking work",
"6": "Full-time student", "7": "Full-time student",
"7": "Unable to work because of long term sick or disability", "8": "Unable to work because of long term sick or disability",
"8": "Child under 16", "100": "Child under 16",
"9": "Other", "0": "Other",
"10": "Prefer not to say" "10": "Prefer not to say"
} }
}, },
@ -380,16 +380,16 @@
"hint_text": "", "hint_text": "",
"type": "radio", "type": "radio",
"answer_options": { "answer_options": {
"0": "Part-time - Less than 30 hours", "2": "Part-time - Less than 30 hours",
"1": "Full-time - 30 hours or more", "1": "Full-time - 30 hours or more",
"2": "In government training into work, such as New Deal", "3": "In government training into work, such as New Deal",
"3": "Jobseeker", "4": "Jobseeker",
"4": "Retired", "5": "Retired",
"5": "Not seeking work", "6": "Not seeking work",
"6": "Full-time student", "7": "Full-time student",
"7": "Unable to work because of long term sick or disability", "8": "Unable to work because of long term sick or disability",
"8": "Child under 16", "100": "Child under 16",
"9": "Other", "0": "Other",
"10": "Prefer not to say" "10": "Prefer not to say"
} }
}, },
@ -432,16 +432,16 @@
"hint_text": "", "hint_text": "",
"type": "radio", "type": "radio",
"answer_options": { "answer_options": {
"0": "Part-time - Less than 30 hours", "2": "Part-time - Less than 30 hours",
"1": "Full-time - 30 hours or more", "1": "Full-time - 30 hours or more",
"2": "In government training into work, such as New Deal", "3": "In government training into work, such as New Deal",
"3": "Jobseeker", "4": "Jobseeker",
"4": "Retired", "5": "Retired",
"5": "Not seeking work", "6": "Not seeking work",
"6": "Full-time student", "7": "Full-time student",
"7": "Unable to work because of long term sick or disability", "8": "Unable to work because of long term sick or disability",
"8": "Child under 16", "100": "Child under 16",
"9": "Other", "0": "Other",
"10": "Prefer not to say" "10": "Prefer not to say"
} }
}, },
@ -484,16 +484,16 @@
"hint_text": "", "hint_text": "",
"type": "radio", "type": "radio",
"answer_options": { "answer_options": {
"0": "Part-time - Less than 30 hours", "2": "Part-time - Less than 30 hours",
"1": "Full-time - 30 hours or more", "1": "Full-time - 30 hours or more",
"2": "In government training into work, such as New Deal", "3": "In government training into work, such as New Deal",
"3": "Jobseeker", "4": "Jobseeker",
"4": "Retired", "5": "Retired",
"5": "Not seeking work", "6": "Not seeking work",
"6": "Full-time student", "7": "Full-time student",
"7": "Unable to work because of long term sick or disability", "8": "Unable to work because of long term sick or disability",
"8": "Child under 16", "100": "Child under 16",
"9": "Other", "0": "Other",
"10": "Prefer not to say" "10": "Prefer not to say"
} }
}, },
@ -536,16 +536,16 @@
"hint_text": "", "hint_text": "",
"type": "radio", "type": "radio",
"answer_options": { "answer_options": {
"0": "Part-time - Less than 30 hours", "2": "Part-time - Less than 30 hours",
"1": "Full-time - 30 hours or more", "1": "Full-time - 30 hours or more",
"2": "In government training into work, such as New Deal", "3": "In government training into work, such as New Deal",
"3": "Jobseeker", "4": "Jobseeker",
"4": "Retired", "5": "Retired",
"5": "Not seeking work", "6": "Not seeking work",
"6": "Full-time student", "7": "Full-time student",
"7": "Unable to work because of long term sick or disability", "8": "Unable to work because of long term sick or disability",
"8": "Child under 16", "100": "Child under 16",
"9": "Other", "0": "Other",
"10": "Prefer not to say" "10": "Prefer not to say"
} }
} }

16
db/migrate/20211103090530_change_field_types.rb

@ -3,6 +3,14 @@ class ChangeFieldTypes < ActiveRecord::Migration[6.1]
change_table :case_logs, bulk: true do |t| change_table :case_logs, bulk: true do |t|
t.change :ethnic, "integer USING ethnic::integer" t.change :ethnic, "integer USING ethnic::integer"
t.change :national, "integer USING national::integer" t.change :national, "integer USING national::integer"
t.change :ecstat1, "integer USING ecstat1::integer"
t.change :ecstat2, "integer USING ecstat2::integer"
t.change :ecstat3, "integer USING ecstat3::integer"
t.change :ecstat4, "integer USING ecstat4::integer"
t.change :ecstat5, "integer USING ecstat5::integer"
t.change :ecstat6, "integer USING ecstat6::integer"
t.change :ecstat7, "integer USING ecstat7::integer"
t.change :ecstat8, "integer USING ecstat8::integer"
end end
end end
@ -10,6 +18,14 @@ class ChangeFieldTypes < ActiveRecord::Migration[6.1]
change_table :case_logs, bulk: true do |t| change_table :case_logs, bulk: true do |t|
t.change :ethnic, :string t.change :ethnic, :string
t.change :national, :string t.change :national, :string
t.change :ecstat1, :string
t.change :ecstat2, :string
t.change :ecstat3, :string
t.change :ecstat4, :string
t.change :ecstat5, :string
t.change :ecstat6, :string
t.change :ecstat7, :string
t.change :ecstat8, :string
end end
end end
end end

20
db/schema.rb

@ -23,39 +23,39 @@ ActiveRecord::Schema.define(version: 2021_11_03_090530) do
t.integer "age1" t.integer "age1"
t.string "sex1" t.string "sex1"
t.integer "ethnic" t.integer "ethnic"
t.string "national" t.integer "national"
t.string "prevten" t.string "prevten"
t.string "armed_forces" t.string "armed_forces"
t.string "ecstat1" t.integer "ecstat1"
t.integer "hhmemb" t.integer "hhmemb"
t.string "relat2" t.string "relat2"
t.integer "age2" t.integer "age2"
t.string "sex2" t.string "sex2"
t.string "ecstat2" t.integer "ecstat2"
t.string "relat3" t.string "relat3"
t.integer "age3" t.integer "age3"
t.string "sex3" t.string "sex3"
t.string "ecstat3" t.integer "ecstat3"
t.string "relat4" t.string "relat4"
t.integer "age4" t.integer "age4"
t.string "sex4" t.string "sex4"
t.string "ecstat4" t.integer "ecstat4"
t.string "relat5" t.string "relat5"
t.integer "age5" t.integer "age5"
t.string "sex5" t.string "sex5"
t.string "ecstat5" t.integer "ecstat5"
t.string "relat6" t.string "relat6"
t.integer "age6" t.integer "age6"
t.string "sex6" t.string "sex6"
t.string "ecstat6" t.integer "ecstat6"
t.string "relat7" t.string "relat7"
t.integer "age7" t.integer "age7"
t.string "sex7" t.string "sex7"
t.string "ecstat7" t.integer "ecstat7"
t.string "relat8" t.string "relat8"
t.integer "age8" t.integer "age8"
t.string "sex8" t.string "sex8"
t.string "ecstat8" t.integer "ecstat8"
t.string "homeless" t.string "homeless"
t.string "reason_for_leaving_last_settled_home" t.string "reason_for_leaving_last_settled_home"
t.string "underoccupation_benefitcap" t.string "underoccupation_benefitcap"
@ -135,7 +135,7 @@ ActiveRecord::Schema.define(version: 2021_11_03_090530) do
t.boolean "override_net_income_validation" t.boolean "override_net_income_validation"
t.string "tenancyother" t.string "tenancyother"
t.string "net_income_known" t.string "net_income_known"
t.index ["discarded_at"], ethnic: "index_case_logs_on_discarded_at" t.index ["discarded_at"], name: "index_case_logs_on_discarded_at"
end end
end end

Loading…
Cancel
Save