Add toggl refetch on loading a page and start to make active cable work
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
class AttendanceTrackerController < ApplicationController
|
||||
before_action :refresh_toggl
|
||||
|
||||
def index
|
||||
@courses = Course.active.sort_by(&:title)
|
||||
@current_lecture = get_current_lecture
|
||||
@@ -41,4 +43,8 @@ class AttendanceTrackerController < ApplicationController
|
||||
|
||||
nil
|
||||
end
|
||||
|
||||
def refresh_toggl
|
||||
ScrapeTogglJob.perform_later
|
||||
end
|
||||
end
|
||||
|
||||
@@ -87,12 +87,16 @@ class ScrapeTogglJob < ApplicationJob
|
||||
toggl_data: entry,
|
||||
associated_toggl_entry_id: entry['time_entries'][0]['id'],
|
||||
)
|
||||
|
||||
broadcast_update_to lecture, :status
|
||||
elsif (lecture_title_match = entry_title.match(review_regex)) and (lecture = lectures.find_by(title: lecture_title_match[1]))
|
||||
lecture.tracked_time_entries.create!(
|
||||
kind: :review,
|
||||
toggl_data: entry,
|
||||
associated_toggl_entry_id: entry['time_entries'][0]['id'],
|
||||
)
|
||||
|
||||
broadcast_update_to lecture, :status
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user