Skip to content

Commit

Permalink
Remove Session#time_of_day
Browse files Browse the repository at this point in the history
This removes the time of day functionality from sessions as we're
removing this from sessions as it's not deemed necessary and not part of
the new session designs.
  • Loading branch information
thomasleese committed Sep 25, 2024
1 parent a37069d commit e1feefe
Show file tree
Hide file tree
Showing 20 changed files with 14 additions and 71 deletions.
5 changes: 0 additions & 5 deletions app/components/app_session_summary_card_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@
row.with_value { dates }
end

summary_list.with_row do |row|
row.with_key { "Time" }
row.with_value { time }
end

summary_list.with_row do |row|
row.with_key { "Cohort" }
row.with_value { cohort }
Expand Down
4 changes: 0 additions & 4 deletions app/components/app_session_summary_card_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ def dates
safe_join(@session.dates.map { _1.value.to_fs(:long_day_of_week) }, tag.br)
end

def time
@session.human_enum_name(:time_of_day)
end

def cohort
I18n.t("children", count: @session.patients.count)
end
Expand Down
3 changes: 1 addition & 2 deletions app/controllers/sessions/edit_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def set_session
def update_params
permitted_attributes = {
location: [:location_id],
when: %i[date(3i) date(2i) date(1i) time_of_day],
when: %i[date(3i) date(2i) date(1i)],
cohort: {
all_patients: nil,
patient_ids: []
Expand Down Expand Up @@ -129,7 +129,6 @@ def validate_params

unless validator.date_params_valid?
@session.date = validator.date_params_as_struct
@session.time_of_day = update_params[:time_of_day]
render_wizard nil, status: :unprocessable_entity
end
when :timeline
Expand Down
17 changes: 2 additions & 15 deletions app/models/immunisation_import_row.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,27 +118,14 @@ def session
return unless valid?

@session ||=
if (
session =
Session.for_date(session_date).find_by(
team:,
location:,
time_of_day: :all_day
)
)
if (session = Session.for_date(session_date).find_by(team:, location:))
unless session.programmes.include?(@programme)
session.programmes << @programme
end
session
else
ActiveRecord::Base.transaction do
session =
Session.create!(
active: false,
team:,
location:,
time_of_day: :all_day
)
session = Session.create!(active: false, team:, location:)
session.dates.create!(value: session_date)
session.programmes << @programme
session
Expand Down
5 changes: 0 additions & 5 deletions app/models/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
# close_consent_at :date
# send_consent_reminders_at :date
# send_consent_requests_at :date
# time_of_day :integer
# created_at :datetime not null
# updated_at :datetime not null
# location_id :bigint
Expand Down Expand Up @@ -50,8 +49,6 @@ class Session < ApplicationRecord
has_many :vaccines, through: :programmes
has_many :batches, through: :vaccines

enum :time_of_day, %w[morning afternoon all_day], validate: { if: :active? }

scope :for_date,
->(value) do
where(
Expand Down Expand Up @@ -86,8 +83,6 @@ class Session < ApplicationRecord

on_wizard_step :when, exact: true do
validates :date, presence: true

validates :time_of_day, inclusion: { in: Session.time_of_days.keys }
end

on_wizard_step :cohort, exact: true do
Expand Down
5 changes: 0 additions & 5 deletions app/views/programmes/sessions.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
<% table.with_head do |head| %>
<% head.with_row do |row| %>
<% row.with_cell(text: "Dates") %>
<% row.with_cell(text: "Time") %>
<% row.with_cell(text: "Location") %>
<% row.with_cell(text: "Consent period") %>
<% row.with_cell(text: "Cohort") %>
Expand All @@ -35,10 +34,6 @@
<span class="nhsuk-table-responsive__heading">Dates</span>
<%= safe_join(session.dates.map { _1.value.to_fs(:long) }, tag.br) %>
<% end %>
<% row.with_cell do %>
<span class="nhsuk-table-responsive__heading">Time</span>
<%= session.time_of_day.humanize %>
<% end %>
<% row.with_cell do %>
<span class="nhsuk-table-responsive__heading">Location</span>
<p class="nhsuk-u-margin-bottom-0 nhsuk-u-secondary-text-color">
Expand Down
2 changes: 1 addition & 1 deletion app/views/sessions/edit/timeline.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<span class="nhsuk-visually-hidden">Information: </span>

<p>
First session scheduled for <%= @session.dates.map(&:value).min.to_fs(:long_day_of_week) %> (<%= @session.human_enum_name(:time_of_day) %>)
First session scheduled for <%= @session.dates.map(&:value).min.to_fs(:long_day_of_week) %>.
</p>
<% end %>
Expand Down
12 changes: 0 additions & 12 deletions app/views/sessions/edit/when.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,5 @@
hint: { text: "For example, 27 3 2017" },
link_errors: true %>
<%= f.govuk_collection_radio_buttons(
:time_of_day,
Session.time_of_days.keys.map do
[_1, Session.human_enum_name("time_of_days", _1)]
end,
:first,
:second,
legend: {
text: "Time",
},
) %>
<%= f.govuk_submit "Continue" %>
<% end %>
5 changes: 0 additions & 5 deletions app/views/sessions/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<%= govuk_table(html_attributes: { class: "nhsuk-table-responsive" }) do |table| %>
<% table.with_head do |head| %>
<% head.with_row do |row| %>
<% row.with_cell(text: "Time", html_attributes: { style: "width: 20%" }) %>
<% row.with_cell(text: "Location") %>
<% row.with_cell(text: "Cohort") %>
<% end %>
Expand All @@ -21,10 +20,6 @@
<% table.with_body do |body| %>
<% @sessions.each do |session| %>
<% body.with_row do |row| %>
<% row.with_cell do %>
<span class="nhsuk-table-responsive__heading">Time</span>
<%= session.time_of_day.humanize %>
<% end %>
<% row.with_cell do %>
<span class="nhsuk-table-responsive__heading">Location</span>
<p class="nhsuk-u-margin-bottom-0 nhsuk-u-secondary-text-color">
Expand Down
2 changes: 0 additions & 2 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,6 @@ en:
missing_day: Enter a day
missing_month: Enter a month
missing_year: Enter a year
time_of_day:
inclusion: Select a time of day
triage:
attributes:
notes:
Expand Down
7 changes: 7 additions & 0 deletions db/migrate/20240925121323_remove_time_of_day_from_sessions.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

class RemoveTimeOfDayFromSessions < ActiveRecord::Migration[7.2]
def change
remove_column :sessions, :time_of_day, :integer
end
end
4 changes: 1 addition & 3 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.2].define(version: 2024_09_25_081048) do
ActiveRecord::Schema[7.2].define(version: 2024_09_25_121323) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"

Expand Down Expand Up @@ -469,15 +469,13 @@
end

create_table "sessions", force: :cascade do |t|
t.date "date"
t.bigint "location_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "active", default: false, null: false
t.date "send_consent_requests_at"
t.date "send_consent_reminders_at"
t.date "close_consent_at"
t.integer "time_of_day"
t.bigint "team_id", null: false
t.index ["team_id"], name: "index_sessions_on_team_id"
end
Expand Down
Binary file modified erd.pdf
Binary file not shown.
3 changes: 1 addition & 2 deletions spec/components/app_session_summary_card_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@
Session.new(
location: create(:location, :school),
programmes: [create(:programme, :hpv)],
date:,
time_of_day: "all_day"
date:
)
end

Expand Down
3 changes: 0 additions & 3 deletions spec/factories/sessions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
# close_consent_at :date
# send_consent_reminders_at :date
# send_consent_requests_at :date
# time_of_day :integer
# created_at :datetime not null
# updated_at :datetime not null
# location_id :bigint
Expand Down Expand Up @@ -38,8 +37,6 @@
send_consent_reminders_at { send_consent_requests_at + 7.days }
close_consent_at { date }

time_of_day { %w[morning afternoon all_day].sample }

active { true }

after(:create) do |session, evaluator|
Expand Down
1 change: 0 additions & 1 deletion spec/features/e2e_journey_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ def when_i_start_creating_a_new_session_by_choosing_school_and_time
fill_in "Day", with: "1"
fill_in "Month", with: "3"
fill_in "Year", with: "2024"
choose "Morning"
click_on "Continue"
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ def and_an_hpv_programme_is_underway
team: @team,
programme: @programme,
location: @location,
date: Date.new(2024, 5, 14),
time_of_day: :all_day
date: Date.new(2024, 5, 14)
)
end

Expand Down
2 changes: 0 additions & 2 deletions spec/features/session_management_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ def when_i_choose_the_date
fill_in "Day", with: "10"
fill_in "Month", with: "03"
fill_in "Year", with: "2024"

choose "Morning"
click_button "Continue"
end

Expand Down
1 change: 0 additions & 1 deletion spec/models/immunisation_import_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@
expect(session.dates.map(&:value)).to contain_exactly(
Date.new(2024, 5, 14)
)
expect(session.time_of_day).to eq("all_day")
end
end

Expand Down
1 change: 0 additions & 1 deletion spec/models/session_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
# close_consent_at :date
# send_consent_reminders_at :date
# send_consent_requests_at :date
# time_of_day :integer
# created_at :datetime not null
# updated_at :datetime not null
# location_id :bigint
Expand Down

0 comments on commit e1feefe

Please sign in to comment.