Backend: Fix N+1 in previousStageJobs

Summary

An N+1 was discovered in previousStageJobs when the work in #422079 (comment 1536884321) was being discussed.

Proposal

The N+1 should be fixed before #389195 (closed) is implemented.

Additional details

Some relevant technical details, if applicable, such as:

  • Does this need a feature flag?
  • Does there need to be an associated instrumentation issue created related to this work?
  • Is there an example response showing the data structure that should be returned (new endpoints only)?
  • What permissions should be used?
  • Is this EE or CE?
    • EE
    • CE
  • Additional comments:

Implementation Table

Group Issue Link
backend 👈 You are here
backend Backend/Frontend: Add new `previousStagesJobs` ... (#389195 - closed)
backend Backend: Fix N+1 in previousStageJobsAndNeeds (#422079 - closed)
backend Backend: Remove GraphQL field - previousStageJo... (#424417)

Links/References

Edited by Mark Nuzzo