From 598c1204e35eb1019d5964a71dd19e00380c0f90 Mon Sep 17 00:00:00 2001 From: Joshua Coles Date: Fri, 29 Sep 2023 21:32:28 +0100 Subject: [PATCH] Move the display to attendances --- app/jobs/scrape_toggl_job.rb | 2 + app/views/attendance_tracker/index.html.erb | 63 ++++++++++----------- 2 files changed, 32 insertions(+), 33 deletions(-) diff --git a/app/jobs/scrape_toggl_job.rb b/app/jobs/scrape_toggl_job.rb index a09c88b..159334c 100644 --- a/app/jobs/scrape_toggl_job.rb +++ b/app/jobs/scrape_toggl_job.rb @@ -25,6 +25,8 @@ class ScrapeTogglJob < ApplicationJob ) lectures.each do |lecture| + return if lecture.attendance.present? + entries_data.each do |entry| concurrent_time_entry = entry['time_entries'].find do |inner_entry| (Time.new(inner_entry['start']) - lecture.start_time) < 10.minutes diff --git a/app/views/attendance_tracker/index.html.erb b/app/views/attendance_tracker/index.html.erb index 4f28d14..3122718 100644 --- a/app/views/attendance_tracker/index.html.erb +++ b/app/views/attendance_tracker/index.html.erb @@ -17,8 +17,8 @@ Action - + <% course.lectures.order(:start_time).group_by { |lecture| lecture.week_number }.each do |(week_number, lectures)| %> Week <%= week_number %> @@ -32,39 +32,36 @@ <%= lecture.start_time.to_fs(:dmy) %> - - <% if lecture.status == 'future' %> - Future - <% elsif lecture.status == 'happening_now' %> - Happening Now - <% elsif lecture.status == 'attended_in_person' %> - - <% elsif lecture.status == 'watched_recording' %> - - <% elsif lecture.status == 'missed' %> - - <% else %> - <% lecture.status %> - <% end %> - - - <% if lecture.status == 'future' %> - <% elsif lecture.status == 'happening_now' && lecture.live_video_url.present? %> - <% link_to "Open live", lecture.live_video_url %> - <% elsif lecture.status == 'attended_in_person' %> - <% link_to "Open recording", lecture.recording_url %> - - <% elsif lecture.status == 'watched_recording' %> - - <% elsif lecture.status == 'missed' %> - - <% else %> - <% lecture.status %> - <% end %> - + <% if lecture.start_time.future? %> + + + + + + <% else %> + + <% if lecture.attendance.nil? %> + + <% elsif lecture.attendance.kind == 'concurrent' %> + + <% elsif lecture.attendance.kind == 'catchup' %> + + <% else %> + <% lecture.attendance.kind %> + <% end %> + + + + <% if lecture.attendance.nil? %> + + <% else %> + <% link_to "Open recording", lecture.recording_url %> + <% end %> + + <% end %> <% end %> <% end %>