`detailed_merge_status` MR API response attribute is slow to respond, returns `checking` often
<!---
Please read this!
Before opening a new issue, make sure to search for keywords in the issues
filtered by the "regression" or "type::bug" label:
- https://gitlab.com/gitlab-org/gitlab/issues?label_name%5B%5D=regression
- https://gitlab.com/gitlab-org/gitlab/issues?label_name%5B%5D=type::bug
and verify the issue you're about to submit isn't a duplicate.
--->
### Summary
<!-- Summarize the bug encountered concisely. -->
The Merge Request API introduced a new attribute for getting the merge status: `detailed_merge_status`. On a larger project, the API did not always return a real state but only `checking` which I assume being a timeout.
The bug was observed in https://gitlab.com/gitlab-com/www-gitlab-com while re-organising the marketing handbook. I wrote a script to check whether the paths I had modified with `git mv` are affected in other merge requests.
### Steps to reproduce
<!-- Describe how one can reproduce the issue - this is very important. Please use an ordered list. -->
1. Query the GitLab API on the Merge Request endpoint on a large project (gitlab-com/www-data-com)
2. Collect the `detailed_merge_status` field from the response and print it while iterating the results
3. Use python-gitlab as library abstract, script in https://gitlab.com/dnsmichi/api-playground/-/blob/main/python/search_mr_contains_path.py
### Example Project
<!-- If possible, please create an example project here on GitLab.com that exhibits the problematic
behavior, and link to it here in the bug report. If you are using an older version of GitLab, this
will also determine whether the bug is fixed in a more recent version. -->
```
wget https://gitlab.com/dnsmichi/api-playground/-/raw/main/python/search_mr_contains_path.py
chmod +x search_mr_contains_path.py
brew install python
pip3 install python-gitlab
export GITLAB_TOKEN=xxx
python3 search_mr_contains_path.py
```
### What is the current *bug* behavior?
<!-- Describe what actually happens. -->
I have seen that the `detailed_merge_status` API field takes a long time to calculate, sometimes, and only returns `checking` as the value then.
Context: I wrote a script that queries the GitLab API and checks whether a path is in the diff changes, and its mergeable status. That helped with re-organising the marketing handbook, and helping other MR authors to rebase.
Script: https://gitlab.com/dnsmichi/api-playground/-/blob/main/python/search_mr_contains_path.py#L62
Output: https://gitlab.com/gitlab-com/www-gitlab-com/-/issues/13991#additional-tasks
### What is the expected *correct* behavior?
<!-- Describe what you should see instead. -->
The `defailed_merge_status` API field returns fast. It should return a result set too, and not `checking` as a value - this is unexpected from an API call, and not documented.
- https://docs.gitlab.com/ee/api/merge_requests.html#response
- https://docs.gitlab.com/ee/api/merge_requests.html#merge-status
### Relevant logs and/or screenshots
<!-- Paste any relevant logs - please use code blocks (```) to format console output, logs, and code
as it's tough to read otherwise. -->
Output from the script in https://gitlab.com/dnsmichi/api-playground/-/blob/main/python/search_mr_contains_path.py
```
- [ ] !115968 - https://gitlab.com/gitlab-com/www-gitlab-com/-/merge_requests/115968+ Status: checking, Title: Updating blog coverage details for contractor assistance - adding clarity
- [ ] !115581 - https://gitlab.com/gitlab-com/www-gitlab-com/-/merge_requests/115581+ Status: ci_must_pass, Title: Deleting Old Partner-Marketing Tech Alliances Page from Handbook
- [ ] !113867 - https://gitlab.com/gitlab-com/www-gitlab-com/-/merge_requests/113867+ Status: checking, Title: Updating the description of how we work together.
- [ ] !111573 - https://gitlab.com/gitlab-com/www-gitlab-com/-/merge_requests/111573+ Status: checking, Title: WIP: Add new directory for Corporate Events
```
### Output of checks
<!-- If you are reporting a bug on GitLab.com, uncomment below -->
This bug happens on GitLab.com
/label ~"reproduced on GitLab.com"
#### Results of GitLab environment info
<!-- Input any relevant GitLab environment information if needed. -->
<details>
<summary>Expand for output related to GitLab environment info</summary>
<pre>
(For installations with omnibus-gitlab package run and paste the output of:
`sudo gitlab-rake gitlab:env:info`)
(For installations from source run and paste the output of:
`sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)
</pre>
</details>
#### Results of GitLab application Check
<!-- Input any relevant GitLab application check information if needed. -->
<details>
<summary>Expand for output related to the GitLab application check</summary>
<pre>
(For installations with omnibus-gitlab package run and paste the output of:
`sudo gitlab-rake gitlab:check SANITIZE=true`)
(For installations from source run and paste the output of:
`sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true`)
(we will only investigate if the tests are passing)
</pre>
</details>
### Possible fixes
<!-- If you can, link to the line of code that might be responsible for the problem. -->
Cache the merge status field. If collecting the different providers takes too long, consider returning a cached result instead of a `checking` attribute, or a proper error ("timeout").
There could also be a performance bug - I have seen the UI slowly responding on the widgets too.
issue