Track associated toggl entry id for uniqueness, show stats for time spent in different parts of the lecture flow.
This commit is contained in:
@@ -10,6 +10,30 @@ class Lecture < ApplicationRecord
|
||||
:problems_class,
|
||||
], default: :lecture
|
||||
|
||||
def prepared?
|
||||
tracked_time_entries.where(kind: [:preparation]).any?
|
||||
end
|
||||
|
||||
def attended?
|
||||
tracked_time_entries.where(kind: [:concurrent, :catchup]).any?
|
||||
end
|
||||
|
||||
def reviewed?
|
||||
tracked_time_entries.where(kind: [:review]).any?
|
||||
end
|
||||
|
||||
def total_preparation_time
|
||||
tracked_time_entries.preparation.sum(&:duration).seconds
|
||||
end
|
||||
|
||||
def total_attendance_time
|
||||
tracked_time_entries.where(kind: [:concurrent, :catchup]).sum(&:duration).seconds
|
||||
end
|
||||
|
||||
def total_review_time
|
||||
tracked_time_entries.review.sum(&:duration).seconds
|
||||
end
|
||||
|
||||
def week_number
|
||||
((start_time.beginning_of_week - course.semester_start_date.to_time) / 1.week).floor + 1
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user