Class: RemoveUnusedTagsJob
Constant Summary
ContainerBrokerBaseJob::JOB_METRIC
Instance Method Summary
collapse
request_id_from_args
Instance Method Details
#any_task_referencing_tag?(task_tag) ⇒ Boolean
22
23
24
|
# File 'app/jobs/remove_unused_tags_job.rb', line 22
def any_task_referencing_tag?(task_tag)
Task.where(tag_expression(task_tag).exists => true).exists?
end
|
6
7
8
|
# File 'app/jobs/remove_unused_tags_job.rb', line 6
def perform(*_args)
remove_unreferenced_tags
end
|
10
11
12
13
14
15
16
|
# File 'app/jobs/remove_unused_tags_job.rb', line 10
def remove_unreferenced_tags
TaskTag
.all
.to_a
.reject { |task_tag| any_task_referencing_tag?(task_tag) }
.each(&:destroy!)
end
|
#tag_expression(task_tag) ⇒ Object
18
19
20
|
# File 'app/jobs/remove_unused_tags_job.rb', line 18
def tag_expression(task_tag)
:"tags.#{task_tag.name}"
end
|