diff options
Diffstat (limited to 'app/graphql/types/ci/job_type.rb')
-rw-r--r-- | app/graphql/types/ci/job_type.rb | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/app/graphql/types/ci/job_type.rb b/app/graphql/types/ci/job_type.rb index 57ff35bcaa5..115cc611072 100644 --- a/app/graphql/types/ci/job_type.rb +++ b/app/graphql/types/ci/job_type.rb @@ -50,8 +50,8 @@ module Types null: true, description: 'How long the job was enqueued before starting.' - field :previous_stage_jobs_and_needs, Types::Ci::JobType.connection_type, null: true, - description: 'All prerequisite jobs.' + field :previous_stage_jobs_or_needs, Types::Ci::JobType.connection_type, null: true, + description: 'Jobs that must complete before the job runs. Returns needed jobs if the job uses the `needs` keyword, and returns previous stage jobs otherwise.' field :detailed_status, Types::Ci::DetailedStatusType, null: true, description: 'Detailed status of the job.' field :artifacts, Types::Ci::JobArtifactType.connection_type, null: true, @@ -103,9 +103,13 @@ module Types end end - def previous_stage_jobs_and_needs - Gitlab::Graphql::Lazy.with_value(previous_stage_jobs) do |jobs| - (jobs + object.needs).uniq(&:name) + def previous_stage_jobs_or_needs + if object.scheduling_type == 'stage' + Gitlab::Graphql::Lazy.with_value(previous_stage_jobs) do |jobs| + jobs + end + else + object.needs end end |