mirror of
https://github.com/bendtherules/github-delete-unused-repos.git
synced 2026-08-18 22:02:57 +00:00
Refactor pagination in GetUserRepo
This commit is contained in:
@@ -22,9 +22,8 @@ interface ResponseWithPaginationAndMeta<T> extends ResponseWithDataArray<T>, Res
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ResponseFromGetUserRepo {
|
interface ResponseFromGetUserRepo extends ResponseWithMetaLink {
|
||||||
data: RepoFromGetUserRepo[];
|
data: RepoFromGetUserRepo[];
|
||||||
meta: {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ResponseFromGetBranches extends ResponseWithMetaLink {
|
interface ResponseFromGetBranches extends ResponseWithMetaLink {
|
||||||
@@ -284,15 +283,17 @@ async function fetchUserIsNotContributor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function fetchUnusedForkedRepos() {
|
async function fetchUnusedForkedRepos() {
|
||||||
const repos: ResponseFromGetUserRepo = await octokit.repos.getForUser({
|
const params: rest.ReposGetForUserParams = {
|
||||||
// tslint:disable-next-line:object-literal-shorthand
|
username,
|
||||||
username: username,
|
}
|
||||||
// type,
|
|
||||||
// sort,
|
const repos: ResponseWithDataArray<RepoFromGetUserRepo> =
|
||||||
// direction,
|
await paginate(
|
||||||
per_page: 100, // solve pagination // change this value // handle abuse detection
|
(tmpFirstParam: rest.ReposGetForUserParams): ResponseFromGetUserRepo => {
|
||||||
// page,
|
return octokit.repos.getForUser(tmpFirstParam) as any as ResponseFromGetUserRepo;
|
||||||
});
|
},
|
||||||
|
params
|
||||||
|
);
|
||||||
|
|
||||||
const forkedRepoNames = repos.data
|
const forkedRepoNames = repos.data
|
||||||
.filter(repo => repo.fork)
|
.filter(repo => repo.fork)
|
||||||
|
|||||||
Reference in New Issue
Block a user