Compare commits
7 Commits
feature/ad
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 090ffe93ca | |||
| 823625d485 | |||
| 3d88280f34 | |||
| ec080c0eb0 | |||
| 19f6c65442 | |||
| 8d03165cfc | |||
| 4b3204d2f4 |
4
Gemfile
4
Gemfile
@ -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"
|
||||
|
||||
|
||||
15
Gemfile.lock
15
Gemfile.lock
@ -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)
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
# Lecture Attendance Management System
|
||||
|
||||
|
||||
## Alterations
|
||||
|
||||
### Continuum Mechanics
|
||||
|
||||
@ -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?
|
||||
|
||||
|
||||
@ -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,
|
||||
)
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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) %>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>LectureAttendanceManager</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
|
||||
@ -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
|
||||
"Join"
|
||||
else
|
||||
"Start"
|
||||
end %>
|
||||
<%= button_to start_label,
|
||||
lectures_start_path(id: lecture.id),
|
||||
class: 'action-button'
|
||||
%>
|
||||
<% 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' %>
|
||||
<% 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 %>
|
||||
|
||||
@ -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
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
Loading…
Reference in New Issue
Block a user