| 402 | return results |
| 403 | |
| 404 | def fetch_pull_requests( |
| 405 | self, numbers: list[int], batch_size: int, workers: int |
| 406 | ) -> dict[int, PullRequestRecord]: |
| 407 | unique_numbers = sorted(set(numbers)) |
| 408 | if not unique_numbers: |
| 409 | return {} |
| 410 | batches = [ |
| 411 | unique_numbers[index : index + batch_size] |
| 412 | for index in range(0, len(unique_numbers), batch_size) |
| 413 | ] |
| 414 | results: dict[int, PullRequestRecord] = {} |
| 415 | if workers <= 1 or len(batches) == 1: |
| 416 | for batch in batches: |
| 417 | results.update(self._fetch_batch(batch)) |
| 418 | return results |
| 419 | |
| 420 | with ThreadPoolExecutor(max_workers=workers) as executor: |
| 421 | future_to_batch = { |
| 422 | executor.submit(self._fetch_batch, batch): batch |
| 423 | for batch in batches |
| 424 | } |
| 425 | for future in as_completed(future_to_batch): |
| 426 | results.update(future.result()) |
| 427 | return results |
| 428 | |
| 429 | |
| 430 | def build_commit_rows( |