Created
September 17, 2021 14:59
-
-
Save jcreed/ab5f75e74d435be6c9446c832bedc826 to your computer and use it in GitHub Desktop.
Auto Program Sync
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ProgramScopeSyncJob | |
extend Resque::FailureRetry | |
include Resque::Plugins::UniqueJob | |
@queue = :low | |
def self.perform(id) | |
new(id).sync_program | |
end | |
attr_accessor :program, :organization | |
def initialize(id) | |
@program = Program.find(id) | |
@organization = program.organization | |
end | |
def sync_program | |
local_statuses_scope_program | |
custom_fields_scope_program | |
applicant_headers_scope_program | |
users_scope_program | |
end | |
private | |
def local_statuses_scope_program | |
local_statuses = organization.local_statuses.with_auto_sync_programs | |
local_statuses.each do |local_status| | |
local_status.program_ids << @program.id | |
end | |
end | |
def custom_fields_scope_program | |
custom_fields = organization.custom_fields.with_auto_sync_programs | |
custom_fields.each do |custom_field| | |
custom_field.program_ids << @program.id | |
end | |
end | |
def applicant_headers_scope_program | |
applicant_headers = organization.applicant_details_headers.with_auto_sync_programs | |
applicant_headers.each do |applicant_header| | |
applicant_header.program_ids << @program.id | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment