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:
parent
4238e4fe4e
commit
e8e143355d
@ -41,6 +41,7 @@ class Course < ApplicationRecord
|
|||||||
short_lecture_title:,
|
short_lecture_title:,
|
||||||
start_time:,
|
start_time:,
|
||||||
event_uuid:,
|
event_uuid:,
|
||||||
|
online: summary.include?("LOIL"),
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -65,6 +66,12 @@ class Course < ApplicationRecord
|
|||||||
title: title,
|
title: title,
|
||||||
start_time: event[:start_time],
|
start_time: event[:start_time],
|
||||||
event_uuid: event[:event_uuid],
|
event_uuid: event[:event_uuid],
|
||||||
|
online: event[:online],
|
||||||
|
live_video_url: if event[:online]
|
||||||
|
self.default_live_video_url
|
||||||
|
else
|
||||||
|
nil
|
||||||
|
end,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -77,4 +84,8 @@ class Course < ApplicationRecord
|
|||||||
end
|
end
|
||||||
end
|
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
|
end
|
||||||
|
|||||||
@ -39,10 +39,6 @@ class Lecture < ApplicationRecord
|
|||||||
tracked_time_entries.review.sum(&:duration).seconds
|
tracked_time_entries.review.sum(&:duration).seconds
|
||||||
end
|
end
|
||||||
|
|
||||||
def live_video_url
|
|
||||||
nil
|
|
||||||
end
|
|
||||||
|
|
||||||
# NAIVE: Assumes that lectures are 50 minutes long, this is true currently but not assured.
|
# NAIVE: Assumes that lectures are 50 minutes long, this is true currently but not assured.
|
||||||
def end_time
|
def end_time
|
||||||
start_time + 50.hour
|
start_time + 50.hour
|
||||||
|
|||||||
@ -0,0 +1,5 @@
|
|||||||
|
class AddDefaultLiveVideoUrlToCourse < ActiveRecord::Migration[7.1]
|
||||||
|
def change
|
||||||
|
add_column :courses, :default_live_video_url, :string
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -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
5
db/schema.rb
generated
@ -10,7 +10,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# 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
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
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.date "semester_start_date", default: "2023-10-02"
|
||||||
t.string "homepage"
|
t.string "homepage"
|
||||||
t.boolean "archived", default: false, null: false
|
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 ["toggl_project"], name: "index_courses_on_toggl_project", unique: true
|
||||||
t.index ["unit_code"], name: "index_courses_on_unit_code", unique: true
|
t.index ["unit_code"], name: "index_courses_on_unit_code", unique: true
|
||||||
end
|
end
|
||||||
@ -37,6 +38,8 @@ ActiveRecord::Schema[7.1].define(version: 2024_02_04_133705) do
|
|||||||
t.string "event_uuid"
|
t.string "event_uuid"
|
||||||
t.boolean "cancelled", default: false
|
t.boolean "cancelled", default: false
|
||||||
t.integer "kind", default: 0
|
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"
|
t.index ["course_id"], name: "index_lectures_on_course_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user