Commit 9fac26f6 authored by Cameron Swords's avatar Cameron Swords

Renamed scopes to better describe what they do

parent 2d8ba98d
......@@ -128,9 +128,9 @@ module Ci
scope :with_stale_live_trace, -> { with_live_trace.finished_before(12.hours.ago) }
scope :finished_before, -> (date) { finished.where('finished_at < ?', date) }
scope :with_secure_report_legacy, -> (job_type) { where('options like :job_type', job_type: "%:artifacts:%:reports:%:#{job_type}:%") }
scope :with_secure_reports_from_options, -> (job_type) { where('options like :job_type', job_type: "%:artifacts:%:reports:%:#{job_type}:%") }
scope :with_secure_reports, -> (job_types) do
scope :with_secure_reports_from_config_options, -> (job_types) do
joins(:metadata).where("ci_builds_metadata.config_options -> 'artifacts' -> 'reports' ?| array[:job_types]", job_types: job_types)
end
......
......@@ -51,16 +51,16 @@ module Security
end
def find_jobs(job_types)
@pipeline.builds.with_secure_reports(job_types)
@pipeline.builds.with_secure_reports_from_config_options(job_types)
end
def find_jobs_legacy(job_types)
# first job type is added as a WHERE statement
query = @pipeline.builds.with_secure_report_legacy(job_types.first)
query = @pipeline.builds.with_secure_reports_from_options(job_types.first)
# following job types are added as OR statements
jobs = job_types.drop(1).reduce(query) do |qry, job_type|
qry.or(@pipeline.builds.with_secure_report_legacy(job_type))
qry.or(@pipeline.builds.with_secure_reports_from_options(job_type))
end
# the query doesn't guarantee accuracy, so we verify it here
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment