Improve query to fetch pipelines with given sha in scope of the project

What does this MR do and why?

During testing of feature introduced in Compare results from all pipelines related to c... (#379108 - closed) we have noticed that feature is working properly on dev and staging environments, however on production it was not working. We've noticed that the reason that this was happening was timeout on database level. After quick investigation we discovered that query introduced in !103283 (merged) was not scoped to the project, and we were querying database for all pipelines with given sha, which was not part of the index. This MR fixes this.

How to set up and validate locally

See !103283 (merged)

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #379108 (closed)

Merge request reports

Loading