Skip to content

Commit b89ba5f

Browse files
committed
feat(bulk-import): rename and refactor pagination functions for improved clarity and consistency
Signed-off-by: Dominik Augustín <daugusti@redhat.com>
1 parent a2216e1 commit b89ba5f

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

  • workspaces/bulk-import/plugins/bulk-import-backend/src/github/utils

workspaces/bulk-import/plugins/bulk-import-backend/src/github/utils/utils.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -392,15 +392,13 @@ export async function listAllRepositoriesForAuthenticatedUser(
392392
});
393393
};
394394

395-
const allPages = await getAllPages(
395+
const allPagesData = await retrieveAllPagesData(
396396
deps,
397397
'repos.listForAuthenticatedUser',
398398
fetchListForAuthenticatedUser,
399399
);
400400

401-
const allRepositories = allPages.flatMap(
402-
pageResponseData => pageResponseData,
403-
);
401+
const allRepositories = allPagesData.flat();
404402

405403
return allRepositories;
406404
}
@@ -423,18 +421,18 @@ export async function listAllRepositoriesAccessibleToInstallation(
423421
});
424422
};
425423

426-
const allPages = await getAllPages(
424+
const allPagesData = await retrieveAllPagesData(
427425
deps,
428426
'apps.listReposAccessibleToInstallation',
429427
fetchListReposAccessibleToInstallation,
430428
);
431429

432-
const allRepositories = allPages.flatMap(
430+
const allRepositories = allPagesData.flatMap(
433431
pageResponseData => pageResponseData.repositories,
434432
);
435433

436-
const total_count = allPages?.[0]?.total_count ?? allRepositories.length;
437-
const repository_selection = allPages?.[0]?.repository_selection;
434+
const total_count = allPagesData?.[0]?.total_count ?? allRepositories.length;
435+
const repository_selection = allPagesData?.[0]?.repository_selection;
438436

439437
return {
440438
repositories: allRepositories,
@@ -443,7 +441,7 @@ export async function listAllRepositoriesAccessibleToInstallation(
443441
};
444442
}
445443

446-
async function getAllPages<ResponseType>(
444+
async function retrieveAllPagesData<ResponseType>(
447445
deps: {
448446
logger: LoggerService;
449447
},

0 commit comments

Comments
 (0)