SuperXtra / githubApi

0 stars 0 forks source link

Suggested architecture #5

Open patrykcelinski opened 4 years ago

patrykcelinski commented 4 years ago

https://github.com/SuperXtra/githubApi/blob/9f55aed6b5491cfd8849cc0dfd6a36333d144756/app/com/scalac/service/CallExternalApi.scala#L36

I think you need to have 4 separate single-method services to handle this:

  1. GetNumberOfProjects* that will call https://api.github.com/orgs/microsoft to get "public_repos": 2974,

  2. GetOrganizationProjects* that will call https://api.github.com/orgs/microsoft/repos to get a list of all projects. Use public_repos from the previous point to do paging. Seems to me that github uses 30 pages.

image

*- maybe use word "project" for "repository" because you might get crazy when you will have something like "RepositoryRepository"

Then for each project:

  1. GetProjectContributors that will call https://api.github.com/repos/microsoft/HealthVault-Mobile-iOS-Library/contributors should return list of { “name”: <contributor_login>, “contributions”: <no_of_contributions> }

  2. Then you need to reduce contributions achieved in the previous step. CountContributions

  3. Get total number of repos

  4. For total number of pages / page size => GetOrganizationProjects to get Future[List[Project]]

  5. For each project in projects list => GetProjectContributors to get Future[List[Contribution]]

  6. Then just reduce this future list of contributions