Skip to content

Commit

Permalink
fetching the database id of the org and repo. Added the IsEmpty flag …
Browse files Browse the repository at this point in the history
…as well
  • Loading branch information
SUSTAPLE117 committed Aug 21, 2024
1 parent dddb9d1 commit cbbc2b2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
6 changes: 4 additions & 2 deletions analyze/analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ type Repository interface {
GetDefaultBranch() string
GetLicense() string
GetIsTemplate() bool
GetOrganizationID() string
GetRepositoryID() string
GetOrganizationID() int
GetRepositoryID() int
GetIsEmpty() bool
}

type RepoBatch struct {
Expand Down Expand Up @@ -330,6 +331,7 @@ func (a *Analyzer) generatePackageInsights(ctx context.Context, tempDir string,
RepoSize: repo.GetSize(),
DefaultBranch: repo.GetDefaultBranch(),
IsFork: repo.GetIsFork(),
IsEmpty: repo.GetIsEmpty(),
ForksCount: repo.GetForksCount(),
StarsCount: repo.GetStarsCount(),
IsTemplate: repo.GetIsTemplate(),
Expand Down
5 changes: 3 additions & 2 deletions models/package_insights.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ type PackageInsights struct {
SourceGitRef string `json:"source_git_ref"`
SourceGitCommitSha string `json:"source_git_commit_sha"`

OrgID string `json:"org_id"`
RepoID string `json:"repo_id"`
OrgID int `json:"org_id"`
RepoID int `json:"repo_id"`
RepoSize int `json:"repo_size"`
DefaultBranch string `json:"default_branch"`
IsFork bool `json:"is_fork"`
IsEmpty bool `json:"is_empty"`
ForksCount int `json:"forks_count"`
StarsCount int `json:"stars_count"`
IsTemplate bool `json:"is_template"`
Expand Down
23 changes: 16 additions & 7 deletions providers/github/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,15 @@ type GithubRepository struct {
StargazerCount int `graphql:"stargazerCount"`
ForkCount int `graphql:"forkCount"`
Owner struct {
ID string `graphql:"id"`
Organization struct {
DatabaseId int `graphql:"databaseId"`
} `graphql:"... on Organization"`
User struct {
DatabaseId int `graphql:"databaseId"`
} `graphql:"... on User"`
} `graphql:"owner"`
RepoID string `graphql:"id"`
RepoSize int `graphql:"diskUsage"` // kilobytes
DatabaseId int `graphql:"databaseId"`
RepoSize int `graphql:"diskUsage"` // kilobytes
DefaultBranchRef struct {
Name string `graphql:"name"`
} `graphql:"defaultBranchRef"`
Expand Down Expand Up @@ -180,12 +185,12 @@ func (gh GithubRepository) GetIsTemplate() bool {
return gh.IsTemplate
}

func (gh GithubRepository) GetOrganizationID() string {
return gh.Owner.ID
func (gh GithubRepository) GetOrganizationID() int {
return gh.Owner.Organization.DatabaseId // even if it's a user, the organization will be filled with the same id
}

func (gh GithubRepository) GetRepositoryID() string {
return gh.RepoID
func (gh GithubRepository) GetRepositoryID() int {
return gh.DatabaseId
}

func (gh GithubRepository) GetForksCount() int {
Expand All @@ -200,6 +205,10 @@ func (gh GithubRepository) GetOpenIssuesCount() int {
return gh.Issues.TotalCount
}

func (gh GithubRepository) GetIsEmpty() bool {
return gh.IsEmpty
}

type Client struct {
restClient *github.Client
graphQLClient *githubv4.Client
Expand Down

0 comments on commit cbbc2b2

Please sign in to comment.