Add started text to table
This commit is contained in:
@@ -1,16 +1,39 @@
|
||||
class AttendanceTrackerController < ApplicationController
|
||||
def index
|
||||
@courses = Course.all.sort_by(&:title)
|
||||
@current_lecture = get_current_lecture
|
||||
end
|
||||
|
||||
def today
|
||||
@courses = Course.all.sort_by(&:title)
|
||||
@date = Date.today
|
||||
|
||||
@current_lecture = get_current_lecture
|
||||
@lectures = @courses.flat_map { |course| course.lectures.filter { |a| a.start_time.today? } }.sort_by { |l| l.start_time }
|
||||
end
|
||||
|
||||
def course_focus
|
||||
@course = Course.find(params[:id])
|
||||
@current_lecture = get_current_lecture
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def get_current_lecture
|
||||
current_time_entry = Toggl.current_time_entry
|
||||
return nil if current_time_entry.nil?
|
||||
|
||||
lecture = Lecture
|
||||
.joins(:course)
|
||||
.find_by(title: current_time_entry['description'], course: { toggl_project: current_time_entry['project_id'] })
|
||||
|
||||
return lecture if lecture.present?
|
||||
|
||||
start_time = Time.new(current_time_entry['start'])
|
||||
lecture = Lecture.joins(:course)
|
||||
.find_by(start_time: (start_time - 10.minutes)..(start_time + 10.minutes), course: { toggl_project: current_time_entry['project_id'] })
|
||||
|
||||
return lecture if lecture.present?
|
||||
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user