Skip to content

Commit 2946bcb

Browse files
authored
Merge pull request #4 from neubig/fix-issue-2
Fix issue #2: Fix pagination
2 parents 2d74d3d + 031e908 commit 2946bcb

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

src/PullRequestViewer.tsx

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,29 @@ const PullRequestViewer: React.FC = () => {
4949
const fetchPullRequests = async () => {
5050
if (selectedRepo) {
5151
try {
52-
const response = await octokit.pulls.list({
53-
owner: 'OpenDevin',
54-
repo: selectedRepo.value,
55-
state: 'open',
56-
});
57-
setPullRequests(response.data);
52+
let allPullRequests: PullRequest[] = [];
53+
let page = 1;
54+
let hasNextPage = true;
55+
56+
while (hasNextPage) {
57+
const response = await octokit.pulls.list({
58+
owner: 'OpenDevin',
59+
repo: selectedRepo.value,
60+
state: 'open',
61+
per_page: 100,
62+
page: page,
63+
});
64+
65+
allPullRequests = [...allPullRequests, ...response.data];
66+
67+
if (response.data.length < 100) {
68+
hasNextPage = false;
69+
} else {
70+
page++;
71+
}
72+
}
73+
74+
setPullRequests(allPullRequests);
5875
} catch (error) {
5976
console.error('Error fetching pull requests:', error);
6077
}

0 commit comments

Comments
 (0)