Compare commits

...

7 Commits

Author SHA1 Message Date
090ffe93ca And lang en
All checks were successful
Build and Publish Docker Container / build (push) Successful in 5m1s
2024-04-09 17:14:13 +01:00
823625d485 Try re-run the systems
All checks were successful
Build and Publish Docker Container / build (push) Successful in 5m5s
2024-02-22 13:50:47 +00:00
3d88280f34 Anddddd fix the method itself
Some checks failed
Build and Publish Docker Container / build (push) Failing after 31m25s
2024-02-07 11:22:02 +00:00
ec080c0eb0 And fix routing...
Some checks failed
Build and Publish Docker Container / build (push) Failing after 16m20s
2024-02-07 11:20:09 +00:00
19f6c65442 Always show the redo toggl entries button
All checks were successful
Build and Publish Docker Container / build (push) Successful in 5m47s
2024-02-07 11:16:58 +00:00
8d03165cfc Remove sidekiq entirely to speed up builds a little and reduce image size
All checks were successful
Build and Publish Docker Container / build (push) Successful in 5m39s
2024-02-07 10:47:46 +00:00
4b3204d2f4 Implement catch-up tracking feature
All checks were successful
Build and Publish Docker Container / build (push) Successful in 5m29s
This update enhances tracking functionality. It adds the ability to track time spent 'catching up' on lectures, with distinctions made within the controllers and views to handle these new 'catch-up' entries. Also implemented a flexible match for lecture titles to include various forms such as 'Lecture 1', 'Lecture 1: Prep' and the 'Catch-up'.
2024-02-07 10:46:47 +00:00
13 changed files with 45 additions and 69 deletions

View File

@ -75,8 +75,8 @@ gem "tailwindcss-rails", "~> 2.0"
gem "font-awesome-sass"
gem "httparty"
gem "sidekiq"
gem 'sidekiq-scheduler'
# gem "sidekiq"
# gem 'sidekiq-scheduler'
gem "icalendar"
gem "administrate"

View File

@ -240,16 +240,12 @@ GEM
rdoc (6.5.0)
psych (>= 4.0.0)
redis (4.8.1)
redis-client (0.17.0)
connection_pool
regexp_parser (2.8.1)
reline (0.3.8)
io-console (~> 0.5)
rexml (3.2.6)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
rufus-scheduler (3.9.1)
fugit (~> 1.1, >= 1.1.6)
sassc (2.4.0)
ffi (~> 1.9)
sassc-rails (2.1.2)
@ -263,15 +259,6 @@ GEM
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
sidekiq (7.1.5)
concurrent-ruby (< 2)
connection_pool (>= 2.3.0)
rack (>= 2.2.4)
redis-client (>= 0.14.0)
sidekiq-scheduler (5.0.3)
rufus-scheduler (~> 3.2)
sidekiq (>= 6, < 8)
tilt (>= 1.4.0)
sprockets (4.2.1)
concurrent-ruby (~> 1.0)
rack (>= 2.2.4, < 4)
@ -336,8 +323,6 @@ DEPENDENCIES
rails (= 7.1.0.rc2)
redis (~> 4.0)
selenium-webdriver
sidekiq
sidekiq-scheduler
sprockets-rails
stimulus-rails
tailwindcss-rails (~> 2.0)

View File

@ -1,5 +1,6 @@
# Lecture Attendance Management System
## Alterations
### Continuum Mechanics

View File

@ -24,9 +24,12 @@ class AttendanceTrackerController < ApplicationController
current_time_entry = Toggl.current_time_entry
return nil if current_time_entry.nil?
# Match both 'Lecture 1' and 'Lecture 1: Prep', etc
lecture_title = current_time_entry['description'].split(':')[0]
lecture = Lecture
.joins(:course)
.find_by(title: current_time_entry['description'], course: { toggl_project: current_time_entry['project_id'] })
.find_by(title: lecture_title, course: { toggl_project: current_time_entry['project_id'] })
return lecture if lecture.present?

View File

@ -13,9 +13,16 @@ class LectureController < ApplicationController
def start
lecture = Lecture.find(params[:id])
catch_up = params[:catch_up].present?
description = if catch_up
"#{lecture.title}: Catch-up"
else
lecture.title
end
Toggl::start_time_entry(
description: lecture.title,
description:,
project_id: lecture.course.toggl_project,
)

View File

@ -80,6 +80,7 @@ class ScrapeTogglJob < ApplicationJob
preparation_regex = /^(.+): ?(?:Prep|Preparation)?$/
review_regex = /^(.+): ?(?:Review|Recap)/
catchup_regex = /^(.+): ?(?:Catch-up|Catch up|Catch Up)/
if (lecture_title_match = entry_title.match(preparation_regex)) and (lecture = lectures.find_by(title: lecture_title_match[1]))
lecture.tracked_time_entries.create!(
@ -96,6 +97,14 @@ class ScrapeTogglJob < ApplicationJob
associated_toggl_entry_id: entry['time_entries'][0]['id'],
)
# broadcast_update_to lecture, :lectures
elsif (lecture_title_match = entry_title.match(catchup_regex)) and (lecture = lectures.find_by(title: lecture_title_match[1]))
lecture.tracked_time_entries.create!(
kind: :catchup,
toggl_data: entry,
associated_toggl_entry_id: entry['time_entries'][0]['id'],
)
# broadcast_update_to lecture, :lectures
end
end

View File

@ -93,7 +93,7 @@ class Course < ApplicationRecord
# Sometimes our toggl entries get mismatched or otherwise out of sync. This method will delete all tracked time entries
# for this course and then re-import them from Toggl.
def redo_toggl_entries!
TrackedTimeEntry.where(lecture: lectures).destroy_all
TrackedTimeEntry.where(subject: lectures).destroy_all
ScrapeTogglJob.perform_later([self.id])
end
end

View File

@ -14,4 +14,4 @@
"Redo Toggl entries",
[namespace, page.resource, :redo_toggl_entries],
class: "button",
) if accessible_action?(page.resource, :redo_toggl_entries) && page.resource.default_live_video_url.present? %>
) if accessible_action?(page.resource, :redo_toggl_entries) %>

View File

@ -1,5 +1,5 @@
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<title>LectureAttendanceManager</title>
<meta name="viewport" content="width=device-width,initial-scale=1">

View File

@ -7,21 +7,25 @@
<% elsif joinable_time.future? %>
<%= button_to "Prepare",
lecture_start_preparation_path(id: lecture.id),
class: 'action-button'
%>
class: 'action-button' %>
<% elsif joinable_time.past? && !lecture.attended? %>
<% start_label = if lecture.is_live? then
<% if lecture.end_time.future? %>
<% start_label = if lecture.is_live?
"Join"
else
"Start"
end %>
<%= button_to start_label,
lectures_start_path(id: lecture.id),
class: 'action-button'
%>
class: 'action-button' %>
<% else %>
<%= button_to 'Catch Up',
lectures_start_path(id: lecture.id, catch_up: true),
class: 'action-button' %>
<% end %>
<% else %>
<%= button_to "Review",
lecture_start_review_path(id: lecture.id),
class: 'action-button'
%>
class: 'action-button' %>
<% end %>

View File

@ -1,7 +0,0 @@
Sidekiq.configure_server do |config|
config.redis = { url: ENV['REDIS_URL'] }
end
Sidekiq.configure_client do |config|
config.redis = { url: ENV['REDIS_URL'] }
end

View File

@ -12,6 +12,7 @@ Rails.application.routes.draw do
get '/courses/:id/renumber_lectures', to: 'courses#renumber_lectures', as: :course_renumber_lectures
get '/courses/:id/fill_in_default_live_video_url', to: 'courses#fill_in_default_live_video_url', as: :course_fill_in_default_live_video_url
get '/courses/:id/redo_toggl_entries', to: 'courses#redo_toggl_entries', as: :course_redo_toggl_entries
end
root controller: :attendance_tracker, action: :overview

View File

@ -1,27 +0,0 @@
---
:concurrency: 5
staging:
:concurrency: 10
production:
:concurrency: 20
:queues:
- default
- mailers
# These are the cron jobs
:scheduler:
:schedule:
:lecture_checkin_job:
# Lectures start at 15 minutes past the hour so run the checkin script just before
cron: '14 * * * 1,2,3,4,5'
class: 'LectureCheckinJob'
queue: default
:scrape_panopto_job:
cron: '* * * * 1,2,3,4,5'
class: 'ScrapePanoptoJob'
queue: default
:scrape_toggl_job:
# Lectures end at 5 past the hour so scrape toggl a little after when I will have ended the time entry
cron: '10 * * * 1,2,3,4,5'
class: 'ScrapeTogglJob'
queue: default