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

copilot: add missing pagination to fetchOrganizationTeams #3170

Closed
wants to merge 6 commits into from

Conversation

christianherweg0807
Copy link

@christianherweg0807 christianherweg0807 commented Mar 6, 2025

Hey, I just made a Pull Request!

This PR adds pagination to the CoPilot backend plugin.

resolves #2087

✔️ Checklist

  • A changeset describing the change and affected packages. (more info)
  • Added or updated documentation
  • Tests for new functionality and regression tests for bug fixes
  • Screenshots attached (for UI changes)
  • All your commits have a Signed-off-by line in the message. (more info)

@christianherweg0807 christianherweg0807 requested a review from a team as a code owner March 6, 2025 10:35
@backstage-goalie
Copy link
Contributor

backstage-goalie bot commented Mar 6, 2025

Changed Packages

Package Name Package Path Changeset Bump Current Version
@backstage-community/plugin-copilot-backend workspaces/copilot/plugins/copilot-backend patch v0.7.0

@backstage-goalie
Copy link
Contributor

Thanks for the contribution!
All commits need to be DCO signed before they are reviewed. Please refer to the the DCO section in CONTRIBUTING.md or the DCO status for more info.

@awanlin
Copy link
Contributor

awanlin commented Mar 6, 2025

Hi @christianherweg0807, if this is a POC then can you move this to be a Draft? That would have avoided reviewers being added. Is there something specific you need which has caused you to open the PR in this state instead of a reviewable contribution? How can the community help?

@christianherweg0807 christianherweg0807 marked this pull request as draft March 6, 2025 13:07
@henrikedegrd
Copy link
Contributor

A suggestion would be to use octokit that have built-in support for pagination.

I am actually planning of doing that myself going forward with more rewrites to include more detailed statistics. But that might take a month or two.

@christianherweg0807
Copy link
Author

@henrikedegrd
octokit would be the right tool, yeah. I didn´t want to introduce a new dependency for this plugin, just for this fix. I simplified the code. This should be ok for now. A rewrite would definitly use octokit.

Would be very interesting to have more detailed statistics. If there is a plugin or project to contribute ... maybe I could add some lines of code.

@christianherweg0807
Copy link
Author

christianherweg0807 commented Mar 6, 2025

I don´t know how to resolve the "Missing Changesets" thing. Any help would be nice.

@christianherweg0807 christianherweg0807 marked this pull request as ready for review March 6, 2025 14:03
@henrikedegrd
Copy link
Contributor

I don´t know how to resolve the "Missing Changesets" thing. Any help would be nice.

https://github.com/backstage/community-plugins/blob/main/CONTRIBUTING.md#creating-changesets

Essentially running yarn changeset in the plugin-folder and writing some information.

@henrikedegrd
Copy link
Contributor

From my part, I would suggest replace all console.warn,error with correct calls to the logger.
That would have to be provided as a dependency to GithubClient from the router.

And probably remove all calls to debug.

Copy link
Member

@04kash 04kash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @christianherweg0807, thanks for taking this on!
In addition to the changes mentioned by @henrikedegrd (adding a changeset and using the LoggerService instead of console.log statements — there are a lot of plugins in this repo using it, let me know if you need examples), you'll also need to resolve the type errors causing the CI to fail.

Copy link
Contributor

@henrikedegrd henrikedegrd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made some suggestions in order to simplify and provide the logger as mandatory.

) {}
logger?: LoggerService,
) {
this.logger = logger || {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -111,4 +153,26 @@ export class GithubClient implements GithubApi {

return response.json() as Promise<T>;
}

// Add this new private method to handle raw responses
private async getRaw(path: string): Promise<NodeFetchResponse> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can possibly be simplified in order to reduce duplicated code.

Maybe the get() can use getRaw() since the only thing that differs is the return.

@04kash
Copy link
Member

04kash commented Mar 14, 2025

@henrikedegrd Thanks for the initial review! Once you've approved this PR, I'll proceed with my review. FYI @christianherweg0807, this is the process we'll follow for reviewing and merging this PR.

@henrikedegrd
Copy link
Contributor

@04kash I have another PR #3241 which also fixes this issue (among also adding new functionality), however I fixed it by changing to octokit.

So this PR might be closed in favor of the octokit-solution?

@awanlin awanlin mentioned this pull request Mar 14, 2025
5 tasks
@04kash
Copy link
Member

04kash commented Mar 14, 2025

So this PR might be closed in favor of the octokit-solution?

Sounds good to me! @christianherweg0807, does that work for you?

@BethGriggs BethGriggs changed the title (fix) Add missing pagination to fetchOrganizationTeams copilot: add missing pagination to fetchOrganizationTeams Mar 18, 2025
@04kash
Copy link
Member

04kash commented Mar 21, 2025

Closing in favour of #3241

@04kash 04kash closed this Mar 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 copilot: does not cater for API pagination (teams)
4 participants