Create TrackedTimeEntry as more general replacement of Attendance to include preparation and review
This commit is contained in:
@@ -3,6 +3,8 @@ class Lecture < ApplicationRecord
|
|||||||
has_one :attendance, dependent: :destroy
|
has_one :attendance, dependent: :destroy
|
||||||
has_one :recording, dependent: :nullify
|
has_one :recording, dependent: :nullify
|
||||||
|
|
||||||
|
has_many :tracked_time_entries, dependent: :destroy
|
||||||
|
|
||||||
enum :kind, [
|
enum :kind, [
|
||||||
:lecture,
|
:lecture,
|
||||||
:problems_class,
|
:problems_class,
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
class TrackedTimeEntry < ApplicationRecord
|
||||||
|
belongs_to :lecture
|
||||||
|
|
||||||
|
enum :kind, [
|
||||||
|
:concurrent,
|
||||||
|
:catchup
|
||||||
|
]
|
||||||
|
|
||||||
|
def duration
|
||||||
|
toggl_data['time_entries'].sum { |entry| entry['seconds'] }
|
||||||
|
.seconds
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
class CreateTrackedTimeEntries < ActiveRecord::Migration[7.1]
|
||||||
|
def change
|
||||||
|
create_table :tracked_time_entries do |t|
|
||||||
|
t.references :lecture, null: false, foreign_key: true
|
||||||
|
t.integer :kind
|
||||||
|
t.jsonb :toggl_data
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||||
|
|
||||||
|
one:
|
||||||
|
lecture: one
|
||||||
|
kind: 1
|
||||||
|
toggl_data:
|
||||||
|
|
||||||
|
two:
|
||||||
|
lecture: two
|
||||||
|
kind: 1
|
||||||
|
toggl_data:
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
require "test_helper"
|
||||||
|
|
||||||
|
class TrackedTimeEntryTest < ActiveSupport::TestCase
|
||||||
|
# test "the truth" do
|
||||||
|
# assert true
|
||||||
|
# end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user