Class: DestroyProjectsJob

Inherits:
ApplicationJob show all
Includes:
Redmine::I18n
Defined in:
app/jobs/destroy_projects_job.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Redmine::I18n

#abbr_day_name, #current_language, #day_letter, #day_name, #find_language, #format_date, #format_hours, #format_time, included, #l, #l_hours, #l_hours_short, #l_or_humanize, #languages_options, #ll, #lu, #month_name, #normalize_float, #set_language_if_valid, #valid_languages

Methods included from Redmine::JobWrapper

#keep_current_user

Class Method Details

.schedule(projects_to_delete, user: User.current) ⇒ Object



6
7
8
9
10
11
12
# File 'app/jobs/destroy_projects_job.rb', line 6

def self.schedule(projects_to_delete, user: User.current)
  # make the projects disappear immediately
  projects_to_delete.each do |project|
    project.self_and_descendants.update_all status: Project::STATUS_SCHEDULED_FOR_DELETION
  end
  perform_later(projects_to_delete.map(&:id), user.id, user.remote_ip)
end

Instance Method Details

#perform(project_ids, user_id, remote_ip) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'app/jobs/destroy_projects_job.rb', line 14

def perform(project_ids, user_id, remote_ip)
  user = User.active.find_by_id(user_id)
  unless user&.admin?
    info "[DestroyProjectsJob] --- User check failed: User #{user_id} triggering projects destroy does not exist anymore or isn't admin/active."
    return
  end

  project_ids.each do |project_id|
    DestroyProjectJob.perform_now(project_id, user_id, remote_ip)
  end
end