Skip to content

Commit

Permalink
Remove deprecated learning_style column from learning_hour (#5048)
Browse files Browse the repository at this point in the history
  • Loading branch information
schoork authored Jul 30, 2023
1 parent b972ae1 commit 20b7077
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 18 deletions.
12 changes: 0 additions & 12 deletions app/models/learning_hour.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,6 @@ class LearningHour < ApplicationRecord
belongs_to :user
belongs_to :learning_hour_type

# Deprecated with Issue 5028
# Delete with Issue 5039 but only AFTER 5028 has been released to prod
enum learning_type: {
book: 1,
movie: 2,
webinar: 3,
conference: 4,
other: 5
}
# End delete

validates :duration_minutes, presence: true
validates :duration_minutes, numericality: {greater_than: 0}, if: :zero_duration_hours?
validates :name, presence: {message: "/ Title cannot be blank"}
Expand Down Expand Up @@ -41,7 +30,6 @@ def occurred_at_not_in_future
# id :bigint not null, primary key
# duration_hours :integer not null
# duration_minutes :integer not null
# learning_type :integer default("other")
# name :string not null
# occurred_at :datetime not null
# created_at :datetime not null
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20230730103110_remove_learning_type.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class RemoveLearningType < ActiveRecord::Migration[7.0]
def change
safety_assured { remove_column :learning_hours, :learning_type, :integer, default: 5, not_null: true }
end
end
3 changes: 1 addition & 2 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.0].define(version: 2023_07_29_213608) do
ActiveRecord::Schema[7.0].define(version: 202307300103110) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"

Expand Down Expand Up @@ -372,7 +372,6 @@

create_table "learning_hours", force: :cascade do |t|
t.bigint "user_id", null: false
t.integer "learning_type", default: 5
t.string "name", null: false
t.integer "duration_minutes", null: false
t.integer "duration_hours", null: false
Expand Down
8 changes: 4 additions & 4 deletions spec/models/learning_hours_report_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
it "includes all learning hours" do
casa_org = build(:casa_org)
users = create_list(:user, 3, casa_org: casa_org)
learning_hour_type = create(:learning_hour_type)
learning_hour_types = create_list(:learning_hour_type, 3)
learning_hours =
[
create(:learning_hour, user: users[0], learning_hour_type: learning_hour_type),
create(:learning_hour, user: users[1], learning_type: :movie, learning_hour_type: learning_hour_type),
create(:learning_hour, user: users[2], learning_type: :webinar, learning_hour_type: learning_hour_type)
create(:learning_hour, user: users[0], learning_hour_type: learning_hour_types[0]),
create(:learning_hour, user: users[1], learning_hour_type: learning_hour_types[1]),
create(:learning_hour, user: users[2], learning_hour_type: learning_hour_types[2])
]
result = CSV.parse(described_class.new(casa_org.id).to_csv)

Expand Down

0 comments on commit 20b7077

Please sign in to comment.