Apps.Github22 icon indicating copy to clipboard operation
Apps.Github22 copied to clipboard

feat: migrate issues GET APIs to GithubSDK

Open JeffreytheCoder opened this issue 10 months ago • 8 comments

Issue(s)

Fixes a part of #143

Acceptance Criteria fulfillment

Completed 6 migration tasks related to issues GET APIs

  • [x] 13. Migrate getIssueTemplates method
  • [x] 14. Migrate getIssueTemplateCode method
  • [x] 20. Migrate getUserAssignedIssues method
  • [x] 21. Migrate getIssueData method
  • [x] 24. Migrate getIssuesComments method
  • [x] 27. Migrate getRepositoryIssues method

JeffreytheCoder avatar Apr 13 '24 23:04 JeffreytheCoder

Hey @JeffreytheCoder great work with the migration I would suggest you attach a Video to show case that the Features are working as expected with new changes.

VipinDevelops avatar Apr 16 '24 07:04 VipinDevelops

Thanks @VipinDevelops! I saw you created a GitHubApi instance for calling getBasicUserInfo in #144 .

https://github.com/RocketChat/Apps.Github22/blob/109aae39cdd45850b3ea12ac885b790251546c5c/github/modals/UserProfileModal.ts#L49-L57

But in this way, everytime we need to call an API, we need to create a instance and fetch properties like access_token and BaseHost.

I'm thinking of creating a GitHubApi singleton on app setup. On creation, the singleton will fetch and store the properties. All app actions can call APIs using the singleton. What do you think?

JeffreytheCoder avatar Apr 17 '24 05:04 JeffreytheCoder

Hey @JeffreytheCoder Yesterday, @samad-yar-khan Also shared about this and suggested a new way to improve this with a nice reference,

Your approach is good, but let me first research the method Samad shared and then I can make a new PR that fixes this issue.

VipinDevelops avatar Apr 18 '24 12:04 VipinDevelops

@JeffreytheCoder @VipinDevelops I was thinking along the same lines as @JeffreytheCoder. We should think about two things while approaching the design for this class

  • It should be easy to use.
  • It should be easy to extend/update.
  • Is there a performance degradation due to fetching of token and URL each time this is used ?
  • Can the user update the base url/token in setting and is the code able to use the updated configuration.

samad-yar-khan avatar May 05 '24 06:05 samad-yar-khan

@samad-yar-khan Thanks for the insights! Like my comment above, I think having token & URL stored in a singleton solves the issue of fetching themevery time. Whenever the user updates token & URL in the settings, we update the singleton too. What do you think?

JeffreytheCoder avatar May 05 '24 20:05 JeffreytheCoder

I agree with @samad-yar-khan. @JeffreytheCoder, can you please implement it that way in this PR? Then, Samad can review it, and we can move forward from there and also update the few places where this new class is being used.

VipinDevelops avatar May 06 '24 04:05 VipinDevelops

Implemented the singleton approach and applied to all migrated methods in this PR and in #144.

Behavior same as before: singleton

JeffreytheCoder avatar May 11 '24 05:05 JeffreytheCoder

The singleton gets api host from environment and generates access token when initialized. We'll need to update these when user update settings / login / logout in another PR.

JeffreytheCoder avatar May 11 '24 06:05 JeffreytheCoder