Track associated toggl entry id for uniqueness, show stats for time spent in different parts of the lecture flow.

This commit is contained in:
2023-10-06 22:00:01 +01:00
parent ef301f6592
commit 0cb03812cf
6 changed files with 135 additions and 47 deletions
+24
View File
@@ -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