Commit e2256451 authored by Payton Burdette's avatar Payton Burdette Committed by Fabio Pitino

Order jobs returned desc

Change the jobs resolver to return
the jobs by order id desc.

Changelog: changed
parent 6bd1a6f6
...@@ -29,7 +29,7 @@ module Resolvers ...@@ -29,7 +29,7 @@ module Resolvers
job_types: security_report_types job_types: security_report_types
).execute ).execute
else else
pipeline.statuses pipeline.statuses_order_id_desc
end end
end end
end end
......
...@@ -18,7 +18,7 @@ module Resolvers ...@@ -18,7 +18,7 @@ module Resolvers
def preloads def preloads
{ {
jobs: { statuses: [:needs] }, jobs: { statuses_order_id_desc: [:needs] },
upstream: [:triggered_by_pipeline], upstream: [:triggered_by_pipeline],
downstream: [:triggered_pipelines] downstream: [:triggered_pipelines]
} }
......
...@@ -63,6 +63,7 @@ module Ci ...@@ -63,6 +63,7 @@ module Ci
has_many :statuses, class_name: 'CommitStatus', foreign_key: :commit_id, inverse_of: :pipeline has_many :statuses, class_name: 'CommitStatus', foreign_key: :commit_id, inverse_of: :pipeline
has_many :latest_statuses_ordered_by_stage, -> { latest.order(:stage_idx, :stage) }, class_name: 'CommitStatus', foreign_key: :commit_id, inverse_of: :pipeline has_many :latest_statuses_ordered_by_stage, -> { latest.order(:stage_idx, :stage) }, class_name: 'CommitStatus', foreign_key: :commit_id, inverse_of: :pipeline
has_many :latest_statuses, -> { latest }, class_name: 'CommitStatus', foreign_key: :commit_id, inverse_of: :pipeline has_many :latest_statuses, -> { latest }, class_name: 'CommitStatus', foreign_key: :commit_id, inverse_of: :pipeline
has_many :statuses_order_id_desc, -> { order_id_desc }, class_name: 'CommitStatus', foreign_key: :commit_id
has_many :processables, class_name: 'Ci::Processable', foreign_key: :commit_id, inverse_of: :pipeline has_many :processables, class_name: 'Ci::Processable', foreign_key: :commit_id, inverse_of: :pipeline
has_many :bridges, class_name: 'Ci::Bridge', foreign_key: :commit_id, inverse_of: :pipeline has_many :bridges, class_name: 'Ci::Bridge', foreign_key: :commit_id, inverse_of: :pipeline
has_many :builds, foreign_key: :commit_id, inverse_of: :pipeline has_many :builds, foreign_key: :commit_id, inverse_of: :pipeline
......
...@@ -224,6 +224,7 @@ ci_pipelines: ...@@ -224,6 +224,7 @@ ci_pipelines:
- ci_ref - ci_ref
- stages - stages
- statuses - statuses
- statuses_order_id_desc
- latest_statuses_ordered_by_stage - latest_statuses_ordered_by_stage
- builds - builds
- bridges - bridges
......
...@@ -28,6 +28,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do ...@@ -28,6 +28,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
it { is_expected.to have_many(:trigger_requests) } it { is_expected.to have_many(:trigger_requests) }
it { is_expected.to have_many(:variables) } it { is_expected.to have_many(:variables) }
it { is_expected.to have_many(:builds) } it { is_expected.to have_many(:builds) }
it { is_expected.to have_many(:statuses_order_id_desc) }
it { is_expected.to have_many(:bridges) } it { is_expected.to have_many(:bridges) }
it { is_expected.to have_many(:job_artifacts).through(:builds) } it { is_expected.to have_many(:job_artifacts).through(:builds) }
it { is_expected.to have_many(:auto_canceled_pipelines) } it { is_expected.to have_many(:auto_canceled_pipelines) }
......
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