From 8c75a31581933577873684f83da740e7963472fe Mon Sep 17 00:00:00 2001 From: Crystal Tenn Date: Tue, 11 Apr 2023 16:55:52 -0400 Subject: [PATCH 1/2] Add per_page: 100 --- src/treeViews/currentBranch.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/treeViews/currentBranch.ts b/src/treeViews/currentBranch.ts index c7b1ce9c..e28dbc9c 100644 --- a/src/treeViews/currentBranch.ts +++ b/src/treeViews/currentBranch.ts @@ -107,7 +107,8 @@ export class CurrentBranchTreeProvider const result = await gitHubRepoContext.client.actions.listWorkflowRunsForRepo({ owner: gitHubRepoContext.owner, repo: gitHubRepoContext.name, - branch: currentBranchName + branch: currentBranchName, + per_page: 100 }); const resp = result.data; From 695cfb9a9100ac0273a656c0efb566c38069ceb5 Mon Sep 17 00:00:00 2001 From: Crystal Tenn Date: Wed, 12 Apr 2023 15:35:11 -0400 Subject: [PATCH 2/2] Add per page 100 to jobs and paginate to get all jobs --- src/store/workflowRun.ts | 46 +++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/src/store/workflowRun.ts b/src/store/workflowRun.ts index 43952510..1001bc2e 100644 --- a/src/store/workflowRun.ts +++ b/src/store/workflowRun.ts @@ -1,3 +1,4 @@ +import * as vscode from "vscode"; import {GitHubRepoContext} from "../git/repository"; import {RepositoryPermission, hasWritePermission} from "../git/repository-permissions"; import {log, logDebug} from "../log"; @@ -76,14 +77,22 @@ export class WorkflowRun extends WorkflowRunBase { override async fetchJobs(): Promise { logDebug("Getting workflow jobs"); - const result = await this._gitHubRepoContext.client.actions.listJobsForWorkflowRun({ - owner: this._gitHubRepoContext.owner, - repo: this._gitHubRepoContext.name, - run_id: this.run.id - }); + let jobs: model.WorkflowJob[] = []; + + try { + jobs = await this._gitHubRepoContext.client.paginate( + this._gitHubRepoContext.client.actions.listJobsForWorkflowRun, + { + owner: this._gitHubRepoContext.owner, + repo: this._gitHubRepoContext.name, + run_id: this.run.id, + per_page: 100 + } + ); + } catch (e) { + await vscode.window.showErrorMessage((e as Error).message); + } - const resp = result.data; - const jobs: model.WorkflowJob[] = resp.jobs; return jobs.map(j => new WorkflowJob(this._gitHubRepoContext, j)); } @@ -139,16 +148,23 @@ export class WorkflowRunAttempt extends WorkflowRunBase { override async fetchJobs(): Promise { logDebug("Getting workflow run attempt jobs", this._run.id, "for attempt", this.attempt); + let jobs: model.WorkflowJob[] = []; - const result = await this._gitHubRepoContext.client.actions.listJobsForWorkflowRunAttempt({ - owner: this._gitHubRepoContext.owner, - repo: this._gitHubRepoContext.name, - run_id: this._run.id, - attempt_number: this.attempt - }); + try { + jobs = await this._gitHubRepoContext.client.paginate( + this._gitHubRepoContext.client.actions.listJobsForWorkflowRunAttempt, + { + owner: this._gitHubRepoContext.owner, + repo: this._gitHubRepoContext.name, + run_id: this.run.id, + attempt_number: this.attempt, + per_page: 100 + } + ); + } catch (e) { + await vscode.window.showErrorMessage((e as Error).message); + } - const resp = result.data; - const jobs: model.WorkflowJob[] = resp.jobs; return jobs.map(j => new WorkflowJob(this._gitHubRepoContext, j)); } }