Add online property and live video URL to lecture models, as well as a default value at the course level

This commit is contained in:
Joshua Coles 2024-02-04 14:23:07 +00:00
parent 4238e4fe4e
commit e8e143355d
5 changed files with 26 additions and 5 deletions

View File

@ -41,6 +41,7 @@ class Course < ApplicationRecord
short_lecture_title:,
start_time:,
event_uuid:,
online: summary.include?("LOIL"),
}
end
@ -65,6 +66,12 @@ class Course < ApplicationRecord
title: title,
start_time: event[:start_time],
event_uuid: event[:event_uuid],
online: event[:online],
live_video_url: if event[:online]
self.default_live_video_url
else
nil
end,
)
end
end
@ -77,4 +84,8 @@ class Course < ApplicationRecord
end
end
end
def fill_in_default_live_video_url!
lectures.where(live_video_url: nil).update!(live_video_url: self.default_live_video_url)
end
end

View File

@ -39,10 +39,6 @@ class Lecture < ApplicationRecord
tracked_time_entries.review.sum(&:duration).seconds
end
def live_video_url
nil
end
# NAIVE: Assumes that lectures are 50 minutes long, this is true currently but not assured.
def end_time
start_time + 50.hour

View File

@ -0,0 +1,5 @@
class AddDefaultLiveVideoUrlToCourse < ActiveRecord::Migration[7.1]
def change
add_column :courses, :default_live_video_url, :string
end
end

View File

@ -0,0 +1,6 @@
class AddOnlineAndLiveVideoUrlToLecture < ActiveRecord::Migration[7.1]
def change
add_column :lectures, :online, :boolean, default: false, null: false
add_column :lectures, :live_video_url, :string
end
end

5
db/schema.rb generated
View File

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.1].define(version: 2024_02_04_133705) do
ActiveRecord::Schema[7.1].define(version: 2024_02_04_141120) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -24,6 +24,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_02_04_133705) do
t.date "semester_start_date", default: "2023-10-02"
t.string "homepage"
t.boolean "archived", default: false, null: false
t.string "default_live_video_url"
t.index ["toggl_project"], name: "index_courses_on_toggl_project", unique: true
t.index ["unit_code"], name: "index_courses_on_unit_code", unique: true
end
@ -37,6 +38,8 @@ ActiveRecord::Schema[7.1].define(version: 2024_02_04_133705) do
t.string "event_uuid"
t.boolean "cancelled", default: false
t.integer "kind", default: 0
t.boolean "online", default: false, null: false
t.string "live_video_url"
t.index ["course_id"], name: "index_lectures_on_course_id"
end