Compare commits
3 Commits
0bf5e17651
...
f850526a59
| Author | SHA1 | Date | |
|---|---|---|---|
| f850526a59 | |||
| e8ea826976 | |||
| bbac184569 |
2
Gemfile
2
Gemfile
@ -79,3 +79,5 @@ gem "sidekiq"
|
||||
gem 'sidekiq-scheduler'
|
||||
gem "icalendar"
|
||||
gem "administrate"
|
||||
|
||||
gem "good_job", "~> 3.23"
|
||||
|
||||
@ -119,6 +119,13 @@ GEM
|
||||
raabro (~> 1.4)
|
||||
globalid (1.2.1)
|
||||
activesupport (>= 6.1)
|
||||
good_job (3.23.0)
|
||||
activejob (>= 6.0.0)
|
||||
activerecord (>= 6.0.0)
|
||||
concurrent-ruby (>= 1.0.2)
|
||||
fugit (>= 1.1)
|
||||
railties (>= 6.0.0)
|
||||
thor (>= 0.14.1)
|
||||
httparty (0.21.0)
|
||||
mini_mime (>= 1.0.0)
|
||||
multi_xml (>= 0.5.2)
|
||||
@ -319,6 +326,7 @@ DEPENDENCIES
|
||||
capybara
|
||||
debug
|
||||
font-awesome-sass
|
||||
good_job (~> 3.23)
|
||||
httparty
|
||||
icalendar
|
||||
importmap-rails
|
||||
|
||||
@ -11,7 +11,8 @@ module LectureAttendanceManager
|
||||
# Initialize configuration defaults for originally generated Rails version.
|
||||
config.load_defaults 7.0
|
||||
|
||||
config.active_job.queue_adapter = :sidekiq
|
||||
# config.active_job.queue_adapter = :sidekiq
|
||||
config.active_job.queue_adapter = :good_job
|
||||
|
||||
config.hosts << "lectures.joshuacoles.me"
|
||||
config.action_controller.forgery_protection_origin_check = false
|
||||
@ -19,12 +20,26 @@ module LectureAttendanceManager
|
||||
# Disable sass to make tailwind work
|
||||
config.assets.css_compressor = nil
|
||||
|
||||
# Configuration for the application, engines, and railties goes here.
|
||||
#
|
||||
# These settings can be overridden in specific environments using the files
|
||||
# in config/environments, which are processed later.
|
||||
#
|
||||
# config.time_zone = "Central Time (US & Canada)"
|
||||
# config.eager_load_paths << Rails.root.join("extras")
|
||||
# Good Job Cron Jobs
|
||||
|
||||
# Enable cron in this process
|
||||
config.good_job.enable_cron = ENV['RUNNER'].present? && ENV['RUNNER'] == '1'
|
||||
|
||||
# Configure cron with a hash that has a unique key for each recurring job
|
||||
config.good_job.cron = {
|
||||
lecture_checkin_job: {
|
||||
cron: '14 * * * 1,2,3,4,5',
|
||||
class: 'LectureCheckinJob',
|
||||
},
|
||||
# TODO: Uncomment when Panopto is used again
|
||||
# scrape_panopto_job: {
|
||||
# cron: '* * * * 1,2,3,4,5',
|
||||
# class: 'ScrapePanoptoJob',
|
||||
# },
|
||||
scrape_toggl_job: {
|
||||
cron: '10 * * * 1,2,3,4,5',
|
||||
class: 'ScrapeTogglJob',
|
||||
},
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
Rails.application.routes.draw do
|
||||
mount GoodJob::Engine => 'good_job'
|
||||
|
||||
namespace :admin do
|
||||
resources :courses
|
||||
resources :lectures
|
||||
|
||||
91
db/migrate/20240207101411_create_good_jobs.rb
Normal file
91
db/migrate/20240207101411_create_good_jobs.rb
Normal file
@ -0,0 +1,91 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class CreateGoodJobs < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
# Uncomment for Postgres v12 or earlier to enable gen_random_uuid() support
|
||||
# enable_extension 'pgcrypto'
|
||||
|
||||
create_table :good_jobs, id: :uuid do |t|
|
||||
t.text :queue_name
|
||||
t.integer :priority
|
||||
t.jsonb :serialized_params
|
||||
t.datetime :scheduled_at
|
||||
t.datetime :performed_at
|
||||
t.datetime :finished_at
|
||||
t.text :error
|
||||
|
||||
t.timestamps
|
||||
|
||||
t.uuid :active_job_id
|
||||
t.text :concurrency_key
|
||||
t.text :cron_key
|
||||
t.uuid :retried_good_job_id
|
||||
t.datetime :cron_at
|
||||
|
||||
t.uuid :batch_id
|
||||
t.uuid :batch_callback_id
|
||||
|
||||
t.boolean :is_discrete
|
||||
t.integer :executions_count
|
||||
t.text :job_class
|
||||
t.integer :error_event, limit: 2
|
||||
t.text :labels, array: true
|
||||
end
|
||||
|
||||
create_table :good_job_batches, id: :uuid do |t|
|
||||
t.timestamps
|
||||
t.text :description
|
||||
t.jsonb :serialized_properties
|
||||
t.text :on_finish
|
||||
t.text :on_success
|
||||
t.text :on_discard
|
||||
t.text :callback_queue_name
|
||||
t.integer :callback_priority
|
||||
t.datetime :enqueued_at
|
||||
t.datetime :discarded_at
|
||||
t.datetime :finished_at
|
||||
end
|
||||
|
||||
create_table :good_job_executions, id: :uuid do |t|
|
||||
t.timestamps
|
||||
|
||||
t.uuid :active_job_id, null: false
|
||||
t.text :job_class
|
||||
t.text :queue_name
|
||||
t.jsonb :serialized_params
|
||||
t.datetime :scheduled_at
|
||||
t.datetime :finished_at
|
||||
t.text :error
|
||||
t.integer :error_event, limit: 2
|
||||
end
|
||||
|
||||
create_table :good_job_processes, id: :uuid do |t|
|
||||
t.timestamps
|
||||
t.jsonb :state
|
||||
end
|
||||
|
||||
create_table :good_job_settings, id: :uuid do |t|
|
||||
t.timestamps
|
||||
t.text :key
|
||||
t.jsonb :value
|
||||
t.index :key, unique: true
|
||||
end
|
||||
|
||||
add_index :good_jobs, :scheduled_at, where: "(finished_at IS NULL)", name: :index_good_jobs_on_scheduled_at
|
||||
add_index :good_jobs, [:queue_name, :scheduled_at], where: "(finished_at IS NULL)", name: :index_good_jobs_on_queue_name_and_scheduled_at
|
||||
add_index :good_jobs, [:active_job_id, :created_at], name: :index_good_jobs_on_active_job_id_and_created_at
|
||||
add_index :good_jobs, :concurrency_key, where: "(finished_at IS NULL)", name: :index_good_jobs_on_concurrency_key_when_unfinished
|
||||
add_index :good_jobs, [:cron_key, :created_at], where: "(cron_key IS NOT NULL)", name: :index_good_jobs_on_cron_key_and_created_at_cond
|
||||
add_index :good_jobs, [:cron_key, :cron_at], where: "(cron_key IS NOT NULL)", unique: true, name: :index_good_jobs_on_cron_key_and_cron_at_cond
|
||||
add_index :good_jobs, [:finished_at], where: "retried_good_job_id IS NULL AND finished_at IS NOT NULL", name: :index_good_jobs_jobs_on_finished_at
|
||||
add_index :good_jobs, [:priority, :created_at], order: { priority: "DESC NULLS LAST", created_at: :asc },
|
||||
where: "finished_at IS NULL", name: :index_good_jobs_jobs_on_priority_created_at_when_unfinished
|
||||
add_index :good_jobs, [:priority, :created_at], order: { priority: "ASC NULLS LAST", created_at: :asc },
|
||||
where: "finished_at IS NULL", name: :index_good_job_jobs_for_candidate_lookup
|
||||
add_index :good_jobs, [:batch_id], where: "batch_id IS NOT NULL"
|
||||
add_index :good_jobs, [:batch_callback_id], where: "batch_callback_id IS NOT NULL"
|
||||
add_index :good_jobs, :labels, using: :gin, where: "(labels IS NOT NULL)", name: :index_good_jobs_on_labels
|
||||
|
||||
add_index :good_job_executions, [:active_job_id, :created_at], name: :index_good_job_executions_on_active_job_id_and_created_at
|
||||
end
|
||||
end
|
||||
81
db/schema.rb
generated
81
db/schema.rb
generated
@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.1].define(version: 2024_02_04_141120) do
|
||||
ActiveRecord::Schema[7.1].define(version: 2024_02_07_101411) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
||||
@ -29,6 +29,85 @@ ActiveRecord::Schema[7.1].define(version: 2024_02_04_141120) do
|
||||
t.index ["unit_code"], name: "index_courses_on_unit_code", unique: true
|
||||
end
|
||||
|
||||
create_table "good_job_batches", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.text "description"
|
||||
t.jsonb "serialized_properties"
|
||||
t.text "on_finish"
|
||||
t.text "on_success"
|
||||
t.text "on_discard"
|
||||
t.text "callback_queue_name"
|
||||
t.integer "callback_priority"
|
||||
t.datetime "enqueued_at"
|
||||
t.datetime "discarded_at"
|
||||
t.datetime "finished_at"
|
||||
end
|
||||
|
||||
create_table "good_job_executions", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.uuid "active_job_id", null: false
|
||||
t.text "job_class"
|
||||
t.text "queue_name"
|
||||
t.jsonb "serialized_params"
|
||||
t.datetime "scheduled_at"
|
||||
t.datetime "finished_at"
|
||||
t.text "error"
|
||||
t.integer "error_event", limit: 2
|
||||
t.index ["active_job_id", "created_at"], name: "index_good_job_executions_on_active_job_id_and_created_at"
|
||||
end
|
||||
|
||||
create_table "good_job_processes", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.jsonb "state"
|
||||
end
|
||||
|
||||
create_table "good_job_settings", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.text "key"
|
||||
t.jsonb "value"
|
||||
t.index ["key"], name: "index_good_job_settings_on_key", unique: true
|
||||
end
|
||||
|
||||
create_table "good_jobs", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.text "queue_name"
|
||||
t.integer "priority"
|
||||
t.jsonb "serialized_params"
|
||||
t.datetime "scheduled_at"
|
||||
t.datetime "performed_at"
|
||||
t.datetime "finished_at"
|
||||
t.text "error"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.uuid "active_job_id"
|
||||
t.text "concurrency_key"
|
||||
t.text "cron_key"
|
||||
t.uuid "retried_good_job_id"
|
||||
t.datetime "cron_at"
|
||||
t.uuid "batch_id"
|
||||
t.uuid "batch_callback_id"
|
||||
t.boolean "is_discrete"
|
||||
t.integer "executions_count"
|
||||
t.text "job_class"
|
||||
t.integer "error_event", limit: 2
|
||||
t.text "labels", array: true
|
||||
t.index ["active_job_id", "created_at"], name: "index_good_jobs_on_active_job_id_and_created_at"
|
||||
t.index ["batch_callback_id"], name: "index_good_jobs_on_batch_callback_id", where: "(batch_callback_id IS NOT NULL)"
|
||||
t.index ["batch_id"], name: "index_good_jobs_on_batch_id", where: "(batch_id IS NOT NULL)"
|
||||
t.index ["concurrency_key"], name: "index_good_jobs_on_concurrency_key_when_unfinished", where: "(finished_at IS NULL)"
|
||||
t.index ["cron_key", "created_at"], name: "index_good_jobs_on_cron_key_and_created_at_cond", where: "(cron_key IS NOT NULL)"
|
||||
t.index ["cron_key", "cron_at"], name: "index_good_jobs_on_cron_key_and_cron_at_cond", unique: true, where: "(cron_key IS NOT NULL)"
|
||||
t.index ["finished_at"], name: "index_good_jobs_jobs_on_finished_at", where: "((retried_good_job_id IS NULL) AND (finished_at IS NOT NULL))"
|
||||
t.index ["labels"], name: "index_good_jobs_on_labels", where: "(labels IS NOT NULL)", using: :gin
|
||||
t.index ["priority", "created_at"], name: "index_good_job_jobs_for_candidate_lookup", where: "(finished_at IS NULL)"
|
||||
t.index ["priority", "created_at"], name: "index_good_jobs_jobs_on_priority_created_at_when_unfinished", order: { priority: "DESC NULLS LAST" }, where: "(finished_at IS NULL)"
|
||||
t.index ["queue_name", "scheduled_at"], name: "index_good_jobs_on_queue_name_and_scheduled_at", where: "(finished_at IS NULL)"
|
||||
t.index ["scheduled_at"], name: "index_good_jobs_on_scheduled_at", where: "(finished_at IS NULL)"
|
||||
end
|
||||
|
||||
create_table "lectures", force: :cascade do |t|
|
||||
t.string "title", null: false
|
||||
t.datetime "start_time", null: false
|
||||
|
||||
Loading…
Reference in New Issue
Block a user