Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimization: Map GitHub API repositories during pagination, not after #9461

Closed
jankeromnes opened this issue Apr 21, 2022 · 0 comments · Fixed by #9462
Closed

Optimization: Map GitHub API repositories during pagination, not after #9461

jankeromnes opened this issue Apr 21, 2022 · 0 comments · Fixed by #9462
Assignees
Labels
component: server git provider: github type: improvement Improves an existing feature or existing code

Comments

@jankeromnes
Copy link
Contributor

Bug description

Follow-up from #9231:

We could try to push our map function into paginate to be more conscious about memory usage

...

so we can drop all fields we do not need before accumulating them in the repositories array.

Relevant code:

const adminRepositories = await octokit.paginate(
octokit.repos.listForAuthenticatedUser,
{ per_page: 100 },
(response) => response.data.filter((r) => !!r.permissions?.admin),
);
return adminRepositories.map((r) => {
return <ProviderRepository>{
name: r.name,
cloneUrl: r.clone_url,
account: r.owner.login,
accountAvatarUrl: r.owner.gravatar_id
? `https://www.gravatar.com/avatar/${r.owner.gravatar_id}?size=128`
: r.owner.avatar_url,
updatedAt: r.updated_at,
};
});

Steps to reproduce

  1. ?

Workspace affected

No response

Expected behavior

No response

Example repository

No response

Anything else?

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: server git provider: github type: improvement Improves an existing feature or existing code
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant