A PullRequest exports two methods for getting all labels: labels() and labelNames(). The first returns List<Label> and the latter returns List<String>. The labelNames method has a default implementation that calls labels() and maps them to the name field. This is ok for most implementations, but not for GitLabMergeRequest.
In GitLabMergeRequest, only the names of the labels are available from the merge_request REST object itself. In order to convert these to Label objects, it needs to make another REST call on the "project" (repository) to get the full label data. This extra call can add up to quite significant amounts of time when processing multiple PullRequest instances.
To make matters worse, the labels in GitLabMergeRequest are initialized in the constructor, so for every GitLabMergeRequest instance created, an extra REST call is made. There is also just a single use of PullRequest::labels() in the whole code base, and that is in the default implementation for labelNames(), so caller is ever interested in the full Label objects. This means that every instance of GitLabMergeRequest is making this extra REST call to initialize a cached set of data that is never used.
I discovered this while investigating why PullRequestBot.getPeriodicItems() was taking so long. Getting rid of any unnecessary REST calls should help reduce execution time here.
In GitLabMergeRequest, only the names of the labels are available from the merge_request REST object itself. In order to convert these to Label objects, it needs to make another REST call on the "project" (repository) to get the full label data. This extra call can add up to quite significant amounts of time when processing multiple PullRequest instances.
To make matters worse, the labels in GitLabMergeRequest are initialized in the constructor, so for every GitLabMergeRequest instance created, an extra REST call is made. There is also just a single use of PullRequest::labels() in the whole code base, and that is in the default implementation for labelNames(), so caller is ever interested in the full Label objects. This means that every instance of GitLabMergeRequest is making this extra REST call to initialize a cached set of data that is never used.
I discovered this while investigating why PullRequestBot.getPeriodicItems() was taking so long. Getting rid of any unnecessary REST calls should help reduce execution time here.
- relates to
-
SKARA-1603 Make labels handling consistent in all Issue implementations
- Resolved