| 428 | |
| 429 | |
| 430 | def build_commit_rows( |
| 431 | commits: list[CommitRecord], |
| 432 | pull_requests: dict[int, PullRequestRecord], |
| 433 | owner: str, |
| 434 | repo: str, |
| 435 | ) -> tuple[list[CommitRow], list[int]]: |
| 436 | rows: list[CommitRow] = [] |
| 437 | missing_prs: set[int] = set() |
| 438 | |
| 439 | for commit in commits: |
| 440 | if commit.pr_number is None: |
| 441 | rows.append( |
| 442 | CommitRow( |
| 443 | commit_hash=commit.commit_hash, |
| 444 | category='Others', |
| 445 | topic='Others', |
| 446 | title=commit.title, |
| 447 | pr_link='', |
| 448 | author=commit.git_author, |
| 449 | labels='', |
| 450 | accepter_1='', |
| 451 | accepter_2='', |
| 452 | accepter_3='', |
| 453 | description='', |
| 454 | ) |
| 455 | ) |
| 456 | continue |
| 457 | |
| 458 | pr_record = pull_requests.get(commit.pr_number) |
| 459 | if pr_record is None: |
| 460 | missing_prs.add(commit.pr_number) |
| 461 | rows.append( |
| 462 | CommitRow( |
| 463 | commit_hash=commit.commit_hash, |
| 464 | category='Others', |
| 465 | topic='Others', |
| 466 | title=commit.title, |
| 467 | pr_link=f'https://github.com/{owner}/{repo}/pull/{commit.pr_number}', |
| 468 | author=commit.git_author, |
| 469 | labels='', |
| 470 | accepter_1='', |
| 471 | accepter_2='', |
| 472 | accepter_3='', |
| 473 | description='', |
| 474 | ) |
| 475 | ) |
| 476 | continue |
| 477 | |
| 478 | accepters = [*pr_record.reviewers, '', '', ''][:3] |
| 479 | rows.append( |
| 480 | CommitRow( |
| 481 | commit_hash=commit.commit_hash, |
| 482 | category=pr_record.category, |
| 483 | topic=pr_record.topic, |
| 484 | title=pr_record.title or commit.title, |
| 485 | pr_link=f'https://github.com/{owner}/{repo}/pull/{commit.pr_number}', |
| 486 | author=pr_record.author or commit.git_author, |
| 487 | labels=','.join(pr_record.labels), |