Compare commits
No commits in common. "main" and "feature/adopt-good-job" have entirely different histories.
main
...
feature/ad
4
Gemfile
4
Gemfile
@ -75,8 +75,8 @@ gem "tailwindcss-rails", "~> 2.0"
|
|||||||
gem "font-awesome-sass"
|
gem "font-awesome-sass"
|
||||||
gem "httparty"
|
gem "httparty"
|
||||||
|
|
||||||
# gem "sidekiq"
|
gem "sidekiq"
|
||||||
# gem 'sidekiq-scheduler'
|
gem 'sidekiq-scheduler'
|
||||||
gem "icalendar"
|
gem "icalendar"
|
||||||
gem "administrate"
|
gem "administrate"
|
||||||
|
|
||||||
|
|||||||
15
Gemfile.lock
15
Gemfile.lock
@ -240,12 +240,16 @@ GEM
|
|||||||
rdoc (6.5.0)
|
rdoc (6.5.0)
|
||||||
psych (>= 4.0.0)
|
psych (>= 4.0.0)
|
||||||
redis (4.8.1)
|
redis (4.8.1)
|
||||||
|
redis-client (0.17.0)
|
||||||
|
connection_pool
|
||||||
regexp_parser (2.8.1)
|
regexp_parser (2.8.1)
|
||||||
reline (0.3.8)
|
reline (0.3.8)
|
||||||
io-console (~> 0.5)
|
io-console (~> 0.5)
|
||||||
rexml (3.2.6)
|
rexml (3.2.6)
|
||||||
ruby2_keywords (0.0.5)
|
ruby2_keywords (0.0.5)
|
||||||
rubyzip (2.3.2)
|
rubyzip (2.3.2)
|
||||||
|
rufus-scheduler (3.9.1)
|
||||||
|
fugit (~> 1.1, >= 1.1.6)
|
||||||
sassc (2.4.0)
|
sassc (2.4.0)
|
||||||
ffi (~> 1.9)
|
ffi (~> 1.9)
|
||||||
sassc-rails (2.1.2)
|
sassc-rails (2.1.2)
|
||||||
@ -259,6 +263,15 @@ GEM
|
|||||||
rexml (~> 3.2, >= 3.2.5)
|
rexml (~> 3.2, >= 3.2.5)
|
||||||
rubyzip (>= 1.2.2, < 3.0)
|
rubyzip (>= 1.2.2, < 3.0)
|
||||||
websocket (~> 1.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)
|
sprockets (4.2.1)
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
rack (>= 2.2.4, < 4)
|
rack (>= 2.2.4, < 4)
|
||||||
@ -323,6 +336,8 @@ DEPENDENCIES
|
|||||||
rails (= 7.1.0.rc2)
|
rails (= 7.1.0.rc2)
|
||||||
redis (~> 4.0)
|
redis (~> 4.0)
|
||||||
selenium-webdriver
|
selenium-webdriver
|
||||||
|
sidekiq
|
||||||
|
sidekiq-scheduler
|
||||||
sprockets-rails
|
sprockets-rails
|
||||||
stimulus-rails
|
stimulus-rails
|
||||||
tailwindcss-rails (~> 2.0)
|
tailwindcss-rails (~> 2.0)
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
# Lecture Attendance Management System
|
# Lecture Attendance Management System
|
||||||
|
|
||||||
|
|
||||||
## Alterations
|
## Alterations
|
||||||
|
|
||||||
### Continuum Mechanics
|
### Continuum Mechanics
|
||||||
|
|||||||
@ -24,12 +24,9 @@ class AttendanceTrackerController < ApplicationController
|
|||||||
current_time_entry = Toggl.current_time_entry
|
current_time_entry = Toggl.current_time_entry
|
||||||
return nil if current_time_entry.nil?
|
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
|
lecture = Lecture
|
||||||
.joins(:course)
|
.joins(:course)
|
||||||
.find_by(title: lecture_title, course: { toggl_project: current_time_entry['project_id'] })
|
.find_by(title: current_time_entry['description'], course: { toggl_project: current_time_entry['project_id'] })
|
||||||
|
|
||||||
return lecture if lecture.present?
|
return lecture if lecture.present?
|
||||||
|
|
||||||
|
|||||||
@ -13,16 +13,9 @@ class LectureController < ApplicationController
|
|||||||
|
|
||||||
def start
|
def start
|
||||||
lecture = Lecture.find(params[:id])
|
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(
|
Toggl::start_time_entry(
|
||||||
description:,
|
description: lecture.title,
|
||||||
project_id: lecture.course.toggl_project,
|
project_id: lecture.course.toggl_project,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -80,7 +80,6 @@ class ScrapeTogglJob < ApplicationJob
|
|||||||
|
|
||||||
preparation_regex = /^(.+): ?(?:Prep|Preparation)?$/
|
preparation_regex = /^(.+): ?(?:Prep|Preparation)?$/
|
||||||
review_regex = /^(.+): ?(?:Review|Recap)/
|
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]))
|
if (lecture_title_match = entry_title.match(preparation_regex)) and (lecture = lectures.find_by(title: lecture_title_match[1]))
|
||||||
lecture.tracked_time_entries.create!(
|
lecture.tracked_time_entries.create!(
|
||||||
@ -97,14 +96,6 @@ class ScrapeTogglJob < ApplicationJob
|
|||||||
associated_toggl_entry_id: entry['time_entries'][0]['id'],
|
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
|
# broadcast_update_to lecture, :lectures
|
||||||
end
|
end
|
||||||
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
|
# 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.
|
# for this course and then re-import them from Toggl.
|
||||||
def redo_toggl_entries!
|
def redo_toggl_entries!
|
||||||
TrackedTimeEntry.where(subject: lectures).destroy_all
|
TrackedTimeEntry.where(lecture: lectures).destroy_all
|
||||||
ScrapeTogglJob.perform_later([self.id])
|
ScrapeTogglJob.perform_later([self.id])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -14,4 +14,4 @@
|
|||||||
"Redo Toggl entries",
|
"Redo Toggl entries",
|
||||||
[namespace, page.resource, :redo_toggl_entries],
|
[namespace, page.resource, :redo_toggl_entries],
|
||||||
class: "button",
|
class: "button",
|
||||||
) if accessible_action?(page.resource, :redo_toggl_entries) %>
|
) if accessible_action?(page.resource, :redo_toggl_entries) && page.resource.default_live_video_url.present? %>
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>LectureAttendanceManager</title>
|
<title>LectureAttendanceManager</title>
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||||
|
|||||||
@ -7,25 +7,21 @@
|
|||||||
<% elsif joinable_time.future? %>
|
<% elsif joinable_time.future? %>
|
||||||
<%= button_to "Prepare",
|
<%= button_to "Prepare",
|
||||||
lecture_start_preparation_path(id: lecture.id),
|
lecture_start_preparation_path(id: lecture.id),
|
||||||
class: 'action-button' %>
|
class: 'action-button'
|
||||||
|
%>
|
||||||
<% elsif joinable_time.past? && !lecture.attended? %>
|
<% elsif joinable_time.past? && !lecture.attended? %>
|
||||||
<% if lecture.end_time.future? %>
|
<% start_label = if lecture.is_live? then
|
||||||
<% start_label = if lecture.is_live?
|
"Join"
|
||||||
"Join"
|
else
|
||||||
else
|
"Start"
|
||||||
"Start"
|
end %>
|
||||||
end %>
|
<%= button_to start_label,
|
||||||
|
lectures_start_path(id: lecture.id),
|
||||||
<%= button_to start_label,
|
class: 'action-button'
|
||||||
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 %>
|
<% else %>
|
||||||
<%= button_to "Review",
|
<%= button_to "Review",
|
||||||
lecture_start_review_path(id: lecture.id),
|
lecture_start_review_path(id: lecture.id),
|
||||||
class: 'action-button' %>
|
class: 'action-button'
|
||||||
|
%>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
7
config/initializers/sidekiq.rb
Normal file
7
config/initializers/sidekiq.rb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
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,7 +12,6 @@ Rails.application.routes.draw do
|
|||||||
|
|
||||||
get '/courses/:id/renumber_lectures', to: 'courses#renumber_lectures', as: :course_renumber_lectures
|
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/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
|
end
|
||||||
|
|
||||||
root controller: :attendance_tracker, action: :overview
|
root controller: :attendance_tracker, action: :overview
|
||||||
|
|||||||
27
config/sidekiq.yml
Normal file
27
config/sidekiq.yml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
---
|
||||||
|
: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