Skip to content

Commit

Permalink
Update result functions
Browse files Browse the repository at this point in the history
- Remove formatCSV functions, which are now unused
- Rename on instnace of `buildJSON` to `buildResult` for consistency

Co-authored-by: David Gardiner <[email protected]>
  • Loading branch information
ipc103 and dmgardiner25 authored Nov 2, 2023
1 parent 5cf6b84 commit 1bd8bc5
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package fetchers

import (
"context"
"fmt"

"github.com/shurcooL/githubv4"
)
Expand Down Expand Up @@ -65,21 +64,6 @@ func (c *ContributionInfoFetcher) Fetch(ctx context.Context) (*map[string]Contri
return result, nil
}

// FormatCSV formats the given data as CSV
func (f *ContributionInfoFetcher) FormatCSV(data []contributionInfo) (string, error) {
csvString := "repo_name,issues_opened\n"
for _, edge := range data {
csvString += fmt.Sprintf("%s\n",
edge.Node.NameWithOwner,
// edge.Node.OpenIssues.TotalCount,
// edge.Node.ClosedIssues.TotalCount,
// edge.Node.OpenPullRequests.TotalCount,
// edge.Node.MergedPullRequests.TotalCount,
)
}
return csvString, nil
}

func (f *ContributionInfoFetcher) buildResult(data []contributionInfo) *map[string]ContributionInfoResult {
result := make(map[string]ContributionInfoResult)
for _, edge := range data {
Expand Down
16 changes: 0 additions & 16 deletions backend/business/core/collectors/github/fetchers/org_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package fetchers

import (
"context"
"fmt"

"github.com/shurcooL/githubv4"
)
Expand Down Expand Up @@ -74,21 +73,6 @@ func (oif *OrgInfoFetcher) Fetch(ctx context.Context) (*OrgInfoResult, error) {
return result, nil
}

func (f *OrgInfoFetcher) formatCSV(data orgInfo) (string, error) {
csvString := "login,name,description,createdAt,totalMembers,totalProjects,totalRepositories,totalTeams\n"
csvString += fmt.Sprintf("%s,%s,%s,%s,%d,%d,%d,%d\n",
data.Login,
data.Name,
data.Description,
data.CreatedAt,
data.MembersWithRole.TotalCount,
data.Projects.TotalCount+data.ProjectsV2.TotalCount,
data.Repositories.TotalCount,
data.Teams.TotalCount,
)
return csvString, nil
}

func (f *OrgInfoFetcher) buildResult(data orgInfo) *OrgInfoResult {
return &OrgInfoResult{
Login: string(data.Login),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,33 +109,11 @@ func (f *ReposInfoFetcher) Fetch(ctx context.Context) (*map[string]RepoInfoResul
variables["reposCursor"] = githubv4.NewString(q.Organization.Repositories.PageInfo.EndCursor)
}

result := f.buildJSON(allRepos)
result := f.buildResult(allRepos)
return result, nil
}

// FormatCSV formats the given data as CSV file
func (f *ReposInfoFetcher) FormatCSV(data []repoInfo) (string, error) {
csvString := "repo_name,collaborators_count,projects_count,discussions_count,forks_count,issues_count,open_issues_count,closed_issues_count,open_pull_requests_count,merged_pull_requests_count,license_name,watchers_count\n"
for _, edge := range data {
csvString += fmt.Sprintf("%s,%d,%d,%d,%d,%d,%d,%d,%d,%d,%s,%d\n",
edge.Node.NameWithOwner,
edge.Node.Collaborators.TotalCount,
edge.Node.Projects.TotalCount+edge.Node.ProjectsV2.TotalCount,
edge.Node.Discussions.TotalCount,
edge.Node.Forks.TotalCount,
edge.Node.Issues.TotalCount,
edge.Node.OpenIssues.TotalCount,
edge.Node.ClosedIssues.TotalCount,
edge.Node.OpenPullRequests.TotalCount,
edge.Node.MergedPullRequests.TotalCount,
edge.Node.LicenseInfo.Name,
edge.Node.Watchers.TotalCount,
)
}
return csvString, nil
}

func (f *ReposInfoFetcher) buildJSON(data []repoInfo) *map[string]RepoInfoResult {
func (f *ReposInfoFetcher) buildResult(data []repoInfo) *map[string]RepoInfoResult {
holder := make(map[string]RepoInfoResult)
for _, edge := range data {
holder[string(edge.Node.NameWithOwner)] = RepoInfoResult{
Expand Down

0 comments on commit 1bd8bc5

Please sign in to comment.