Skip to content

Commit 695cfb9

Browse files
author
Crystal Tenn
committed
Add per page 100 to jobs and paginate to get all jobs
1 parent 8c75a31 commit 695cfb9

File tree

1 file changed

+31
-15
lines changed

1 file changed

+31
-15
lines changed

src/store/workflowRun.ts

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import * as vscode from "vscode";
12
import {GitHubRepoContext} from "../git/repository";
23
import {RepositoryPermission, hasWritePermission} from "../git/repository-permissions";
34
import {log, logDebug} from "../log";
@@ -76,14 +77,22 @@ export class WorkflowRun extends WorkflowRunBase {
7677
override async fetchJobs(): Promise<WorkflowJob[]> {
7778
logDebug("Getting workflow jobs");
7879

79-
const result = await this._gitHubRepoContext.client.actions.listJobsForWorkflowRun({
80-
owner: this._gitHubRepoContext.owner,
81-
repo: this._gitHubRepoContext.name,
82-
run_id: this.run.id
83-
});
80+
let jobs: model.WorkflowJob[] = [];
81+
82+
try {
83+
jobs = await this._gitHubRepoContext.client.paginate(
84+
this._gitHubRepoContext.client.actions.listJobsForWorkflowRun,
85+
{
86+
owner: this._gitHubRepoContext.owner,
87+
repo: this._gitHubRepoContext.name,
88+
run_id: this.run.id,
89+
per_page: 100
90+
}
91+
);
92+
} catch (e) {
93+
await vscode.window.showErrorMessage((e as Error).message);
94+
}
8495

85-
const resp = result.data;
86-
const jobs: model.WorkflowJob[] = resp.jobs;
8796
return jobs.map(j => new WorkflowJob(this._gitHubRepoContext, j));
8897
}
8998

@@ -139,16 +148,23 @@ export class WorkflowRunAttempt extends WorkflowRunBase {
139148

140149
override async fetchJobs(): Promise<WorkflowJob[]> {
141150
logDebug("Getting workflow run attempt jobs", this._run.id, "for attempt", this.attempt);
151+
let jobs: model.WorkflowJob[] = [];
142152

143-
const result = await this._gitHubRepoContext.client.actions.listJobsForWorkflowRunAttempt({
144-
owner: this._gitHubRepoContext.owner,
145-
repo: this._gitHubRepoContext.name,
146-
run_id: this._run.id,
147-
attempt_number: this.attempt
148-
});
153+
try {
154+
jobs = await this._gitHubRepoContext.client.paginate(
155+
this._gitHubRepoContext.client.actions.listJobsForWorkflowRunAttempt,
156+
{
157+
owner: this._gitHubRepoContext.owner,
158+
repo: this._gitHubRepoContext.name,
159+
run_id: this.run.id,
160+
attempt_number: this.attempt,
161+
per_page: 100
162+
}
163+
);
164+
} catch (e) {
165+
await vscode.window.showErrorMessage((e as Error).message);
166+
}
149167

150-
const resp = result.data;
151-
const jobs: model.WorkflowJob[] = resp.jobs;
152168
return jobs.map(j => new WorkflowJob(this._gitHubRepoContext, j));
153169
}
154170
}

0 commit comments

Comments
 (0)