Add toggl refetch on loading a page and start to make active cable work

This commit is contained in:
2024-02-04 17:40:09 +00:00
parent 6e85c4103a
commit 2926cfdbea
3 changed files with 13 additions and 3 deletions
@@ -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
+4
View File
@@ -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