From 706093cc9cd7bc355c8e8b406b30f13303112264 Mon Sep 17 00:00:00 2001 From: Maxim Sukharev Date: Mon, 14 Oct 2019 12:03:37 +0200 Subject: [PATCH] Tidy github provider 1. Remove not needed fields like `billing_email` 2. Remove non-exiting fields like `clone_url` 3. Use golint compatible names everywhere Ref: #35 Signed-off-by: Maxim Sukharev --- database/migrations/000001_init.up.sql | 5 -- github/downloader.go | 30 +++---- github/downloader_test.go | 4 +- github/graphql/types.go | 79 ++++++++---------- github/store/db.go | 111 ++++++++++++------------- 5 files changed, 103 insertions(+), 126 deletions(-) diff --git a/database/migrations/000001_init.up.sql b/database/migrations/000001_init.up.sql index b36c109..021e6eb 100644 --- a/database/migrations/000001_init.up.sql +++ b/database/migrations/000001_init.up.sql @@ -5,21 +5,18 @@ CREATE TABLE IF NOT EXISTS organizations_versioned ( versions integer ARRAY, avatar_url text, - billing_email text, collaborators bigint, created_at timestamptz, description text, email text, htmlurl text, id bigint, - location text, login text, name text, node_id text, owned_private_repos bigint, public_repos bigint, total_private_repos bigint, - two_factor_requirement_enabled boolean, updated_at timestamptz ); @@ -47,7 +44,6 @@ CREATE TABLE IF NOT EXISTS users_versioned ( private_gists bigint, public_gists bigint, public_repos bigint, - site_admin boolean, total_private_repos bigint, updated_at timestamptz ); @@ -76,7 +72,6 @@ CREATE TABLE IF NOT EXISTS repositories_versioned ( htmlurl text, id bigint, language text, - mirror_url text, name text, node_id text, open_issues_count bigint, diff --git a/github/downloader.go b/github/downloader.go index e6b3ed2..3622ddd 100644 --- a/github/downloader.go +++ b/github/downloader.go @@ -38,7 +38,7 @@ type storer interface { SavePullRequest(ctx context.Context, repositoryOwner, repositoryName string, pr *graphql.PullRequest, assignees []string, labels []string) error SavePullRequestComment(ctx context.Context, repositoryOwner, repositoryName string, pullRequestNumber int, comment *graphql.IssueComment) error SavePullRequestReview(ctx context.Context, repositoryOwner, repositoryName string, pullRequestNumber int, review *graphql.PullRequestReview) error - SavePullRequestReviewComment(ctx context.Context, repositoryOwner, repositoryName string, pullRequestNumber int, pullRequestReviewId int, comment *graphql.PullRequestReviewComment) error + SavePullRequestReviewComment(ctx context.Context, repositoryOwner, repositoryName string, pullRequestNumber int, pullRequestReviewID int, comment *graphql.PullRequestReviewComment) error Begin() error Commit() error @@ -197,7 +197,7 @@ func (d Downloader) downloadTopics(ctx context.Context, repository *graphql.Repo } variables := map[string]interface{}{ - "id": githubv4.ID(repository.Id), + "id": githubv4.ID(repository.ID), "repositoryTopicsPage": githubv4.Int(repositoryTopicsPage), "repositoryTopicsCursor": (*githubv4.String)(nil), @@ -269,7 +269,7 @@ func (d Downloader) downloadIssues(ctx context.Context, owner string, name strin } variables := map[string]interface{}{ - "id": githubv4.ID(repository.Id), + "id": githubv4.ID(repository.ID), "assigneesPage": githubv4.Int(assigneesPage), "issueCommentsPage": githubv4.Int(issueCommentsPage), @@ -331,7 +331,7 @@ func (d Downloader) downloadIssueAssignees(ctx context.Context, issue *graphql.I } variables := map[string]interface{}{ - "id": githubv4.ID(issue.Id), + "id": githubv4.ID(issue.ID), "assigneesPage": githubv4.Int(assigneesPage), "assigneesCursor": (*githubv4.String)(nil), @@ -378,7 +378,7 @@ func (d Downloader) downloadIssueLabels(ctx context.Context, issue *graphql.Issu } variables := map[string]interface{}{ - "id": githubv4.ID(issue.Id), + "id": githubv4.ID(issue.ID), "labelsPage": githubv4.Int(labelsPage), "labelsCursor": (*githubv4.String)(nil), @@ -426,7 +426,7 @@ func (d Downloader) downloadIssueComments(ctx context.Context, owner string, nam } variables := map[string]interface{}{ - "id": githubv4.ID(issue.Id), + "id": githubv4.ID(issue.ID), "issueCommentsPage": githubv4.Int(issueCommentsPage), "issueCommentsCursor": (*githubv4.String)(nil), @@ -510,7 +510,7 @@ func (d Downloader) downloadPullRequests(ctx context.Context, owner string, name } variables := map[string]interface{}{ - "id": githubv4.ID(repository.Id), + "id": githubv4.ID(repository.ID), "assigneesPage": githubv4.Int(assigneesPage), "issueCommentsPage": githubv4.Int(issueCommentsPage), @@ -576,7 +576,7 @@ func (d Downloader) downloadPullRequestAssignees(ctx context.Context, pr *graphq } variables := map[string]interface{}{ - "id": githubv4.ID(pr.Id), + "id": githubv4.ID(pr.ID), "assigneesPage": githubv4.Int(assigneesPage), "assigneesCursor": (*githubv4.String)(nil), @@ -623,7 +623,7 @@ func (d Downloader) downloadPullRequestLabels(ctx context.Context, pr *graphql.P } variables := map[string]interface{}{ - "id": githubv4.ID(pr.Id), + "id": githubv4.ID(pr.ID), "labelsPage": githubv4.Int(assigneesPage), "labelsCursor": (*githubv4.String)(nil), @@ -671,7 +671,7 @@ func (d Downloader) downloadPullRequestComments(ctx context.Context, owner strin } variables := map[string]interface{}{ - "id": githubv4.ID(pr.Id), + "id": githubv4.ID(pr.ID), "issueCommentsPage": githubv4.Int(issueCommentsPage), "issueCommentsCursor": (*githubv4.String)(nil), @@ -730,7 +730,7 @@ func (d Downloader) downloadPullRequestReviews(ctx context.Context, owner string } variables := map[string]interface{}{ - "id": githubv4.ID(pr.Id), + "id": githubv4.ID(pr.ID), "pullRequestReviewCommentsPage": githubv4.Int(pullRequestReviewCommentsPage), "pullRequestReviewsPage": githubv4.Int(pullRequestReviewsPage), @@ -776,11 +776,11 @@ func (d Downloader) downloadPullRequestReviews(ctx context.Context, owner string func (d Downloader) downloadReviewComments(ctx context.Context, repositoryOwner, repositoryName string, pullRequestNumber int, review *graphql.PullRequestReview) error { process := func(comment *graphql.PullRequestReviewComment) error { - err := d.storer.SavePullRequestReviewComment(ctx, repositoryOwner, repositoryName, pullRequestNumber, review.DatabaseId, comment) + err := d.storer.SavePullRequestReviewComment(ctx, repositoryOwner, repositoryName, pullRequestNumber, review.DatabaseID, comment) if err != nil { return fmt.Errorf( "failed to save PullRequestReviewComment for PR #%v, review ID %v: %v", - pullRequestNumber, review.Id, err) + pullRequestNumber, review.ID, err) } return nil @@ -795,7 +795,7 @@ func (d Downloader) downloadReviewComments(ctx context.Context, repositoryOwner, } variables := map[string]interface{}{ - "id": githubv4.ID(review.Id), + "id": githubv4.ID(review.ID), "pullRequestReviewCommentsPage": githubv4.Int(pullRequestReviewCommentsPage), "pullRequestReviewCommentsCursor": (*githubv4.String)(nil), @@ -820,7 +820,7 @@ func (d Downloader) downloadReviewComments(ctx context.Context, repositoryOwner, if err != nil { return fmt.Errorf( "failed to query PR review comments for PR #%v, review ID %v: %v", - pullRequestNumber, review.Id, err) + pullRequestNumber, review.ID, err) } for _, comment := range q.Node.PullRequestReview.Comments.Nodes { diff --git a/github/downloader_test.go b/github/downloader_test.go index 0a16be5..594c70a 100644 --- a/github/downloader_test.go +++ b/github/downloader_test.go @@ -91,7 +91,7 @@ func testOnlineRepo(t *testing.T, oracle RepositoryTest, d *Downloader, storer * require := require.New(t) // Make a new require object for the specified test, so no need to pass it around require.Nil(err) // Sample some properties that will not change, no topics available in git-fixtures - require.Equal(oracle.URL, storer.Repository.Url) + require.Equal(oracle.URL, storer.Repository.URL) require.Equal(oracle.CreatedAt, storer.Repository.CreatedAt.String()) require.Equal(oracle.IsPrivate, storer.Repository.IsPrivate) require.Equal(oracle.IsArchived, storer.Repository.IsArchived) @@ -125,7 +125,7 @@ func testOnlineOrg(t *testing.T, oracle OrganizationTest, d *Downloader, storer require.Nil(err, "DownloadOrganization(%s) failed", oracle.Org) // Sample some properties that will not change, no topics available in git-fixtures require.Equal(oracle.Org, storer.Organization.Name) - require.Equal(oracle.URL, storer.Organization.Url) + require.Equal(oracle.URL, storer.Organization.URL) require.Equal(oracle.CreatedAt, storer.Organization.CreatedAt.String()) require.Equal(oracle.PublicRepos, storer.Organization.PublicRepos.TotalCount) require.Equal(oracle.TotalPrivateRepos, storer.Organization.TotalPrivateRepos.TotalCount) diff --git a/github/graphql/types.go b/github/graphql/types.go index 8247c6f..b9bb893 100644 --- a/github/graphql/types.go +++ b/github/graphql/types.go @@ -23,18 +23,15 @@ type Organization struct { // OrganizationFields defines the fields for Organization // https://developer.github.com/v4/object/organization/ type OrganizationFields struct { - AvatarUrl string // avatar_url text, - // TODO: requires admin:org scope - //OrganizationBillingEmail string // billing_email text, + AvatarURL string // avatar_url text, CreatedAt time.Time // created_at timestamptz, Description string // description text, Email string // email text, - Url string // htmlurl text, - DatabaseId int // id bigint, - Location string // location text, + URL string // htmlurl text, + DatabaseID int // id bigint, Login string // login text, Name string // name text, - Id string // node_id text, + ID string // node_id text, OwnedPrivateRepos struct { TotalCount int // owned_private_repos bigint, } `graphql:"owned_private_repos: repositories(privacy:PRIVATE, ownerAffiliations:OWNER)"` @@ -44,8 +41,6 @@ type OrganizationFields struct { TotalPrivateRepos struct { TotalCount int // total_private_repos bigint, } `graphql:"total_private_repos: repositories(privacy:PRIVATE)"` - // TODO: requires admin:org scope - //RequiresTwoFactorAuthentication bool // two_factor_requirement_enabled boolean, UpdatedAt string // updated_at timestamptz, } @@ -58,7 +53,7 @@ type OrganizationMemberConnection struct { // UserExtended is the same type as User, but requesting more fields. // Represents https://developer.github.com/v4/object/user/ type UserExtended struct { - AvatarUrl string // avatar_url text, + AvatarURL string // avatar_url text, Bio string // bio text, Company string // company text, CreatedAt time.Time // created_at timestamptz, @@ -71,12 +66,12 @@ type UserExtended struct { TotalCount int // following bigint, } IsHireable bool // hireable boolean, - Url string // htmlurl text, - DatabaseId int // id bigint, + URL string // htmlurl text, + DatabaseID int // id bigint, Location string // location text, Login string // login text, Name string // name text, - Id string // node_id text, + ID string // node_id text, OwnedPrivateRepos struct { TotalCount int // owned_private_repos bigint, } `graphql:"owned_private_repos: repositories(privacy:PRIVATE, ownerAffiliations:OWNER)"` @@ -92,7 +87,6 @@ type UserExtended struct { PublicRepos struct { TotalCount int // public_repos bigint, } `graphql:"public_repos: repositories(privacy:PUBLIC)"` - IsSiteAdmin bool // site_admin boolean, TotalPrivateRepos struct { TotalCount int // total_private_repos bigint, } `graphql:"total_private_repos: repositories(privacy:PRIVATE)"` @@ -114,7 +108,6 @@ type RepositoryFields struct { RebaseMergeAllowed bool // allow_rebase_merge boolean SquashMergeAllowed bool // allow_squash_merge boolean IsArchived bool // archived boolean - Url string // clone_url text CreatedAt time.Time // created_at timestamptz DefaultBranchRef struct { Name string // default_branch text @@ -126,32 +119,30 @@ type RepositoryFields struct { NameWithOwner string // full_name text HasIssuesEnabled bool // has_issues boolean HasWikiEnabled bool // has_wiki boolean - HomepageUrl string // homepage text - //Url string // htmlurl text - DatabaseId int // id bigint, - PrimaryLanguage struct { + HomepageURL string // homepage text + URL string // htmlurl text + DatabaseID int // id bigint, + PrimaryLanguage struct { Name string // language text } - MirrorUrl string // mirror_url text Name string // name text - Id string // node_id text + ID string // node_id text OpenIssues struct { TotalCount int // open_issues_count bigint } `graphql:"openIssues: issues(states:[OPEN])"` Owner struct { Organization struct { - DatabaseId int // owner_id bigint NOT NULL, + DatabaseID int // owner_id bigint NOT NULL, } `graphql:"... on Organization"` User struct { - DatabaseId int // owner_id bigint NOT NULL, + DatabaseID int // owner_id bigint NOT NULL, } `graphql:"... on User"` Login string // owner_login text NOT NULL, Typename string `graphql:"__typename"` // owner_type text NOT NULL } - IsPrivate bool // private boolean PushedAt time.Time // pushed_at timestamptz - SshUrl string // sshurl text + SSHURL string // sshurl text Stargazers struct { TotalCount int // stargazers_count bigint } @@ -193,8 +184,8 @@ type Issue struct { // User represents https://developer.github.com/v4/object/user/ type User struct { - DatabaseId int - Id string + DatabaseID int + ID string Login string } @@ -208,14 +199,14 @@ type IssueFields struct { Body string // body text, ClosedAt time.Time // closed_at timestamptz, CreatedAt time.Time // created_at timestamptz, - Url string // htmlurl text, - DatabaseId int // id bigint, + URL string // htmlurl text, + DatabaseID int // id bigint, Locked bool // locked boolean, Milestone struct { - Id string // milestone_id text NOT NULL, + ID string // milestone_id text NOT NULL, Title string // milestone_title text NOT NULL, } - Id string // node_id text, + ID string // node_id text, Number int // number bigint, State string // state text, Title string // title text, @@ -252,9 +243,9 @@ type IssueComment struct { AuthorAssociation string // author_association text, Body string // body text, CreatedAt time.Time // created_at timestamptz, - Url string // htmlurl text, - DatabaseId int // id bigint, - Id string // node_id text, + URL string // htmlurl text, + DatabaseID int // id bigint, + ID string // node_id text, UpdatedAt string // updated_at timestamptz, Author Actor // user_id bigint NOT NULL, user_login text NOT NULL, } @@ -305,8 +296,8 @@ type PullRequestFields struct { CreatedAt time.Time // created_at timestamptz, Deletions int // deletions bigint, HeadRef Ref // head_* - Url string // htmlurl text, - DatabaseId int // id bigint, + URL string // htmlurl text, + DatabaseID int // id bigint, MaintainerCanModify bool // maintainer_can_modify boolean, MergeCommit struct { Oid string // merge_commit_sha text, @@ -316,10 +307,10 @@ type PullRequestFields struct { MergedAt time.Time // merged_at timestamptz, MergedBy Actor // merged_by_id bigint NOT NULL, merged_by_login text NOT NULL, Milestone struct { - Id string // milestone_id text NOT NULL, + ID string // milestone_id text NOT NULL, Title string // milestone_title text NOT NULL, } - Id string // node_id text, + ID string // node_id text, Number int // number bigint, ReviewThreads struct { TotalCount int // review_comments bigint, @@ -345,9 +336,9 @@ type PullRequestReviewFields struct { Commit struct { Oid string // commit_id text, } - Url string // htmlurl text, - DatabaseId int // id bigint, - Id string // node_id text, + URL string // htmlurl text, + DatabaseID int // id bigint, + ID string // node_id text, State string // state text, SubmittedAt time.Time // submitted_at timestamptz, Author Actor // user_id bigint NOT NULL, user_login text NOT NULL, @@ -368,10 +359,10 @@ type PullRequestReviewComment struct { } CreatedAt time.Time // created_at timestamptz, DiffHunk string // diff_hunk text, - Url string // htmlurl text, - DatabaseId int // id bigint, + URL string // htmlurl text, + DatabaseID int // id bigint, //in_reply_to string // in_reply_to bigint, - Id string // node_id text, + ID string // node_id text, OriginalCommit struct { Oid string // original_commit_id text, } diff --git a/github/store/db.go b/github/store/db.go index e0fb5b0..2d6f405 100644 --- a/github/store/db.go +++ b/github/store/db.go @@ -36,9 +36,9 @@ func (s *DB) Version(v int) { } const ( - organizationsCols = "avatar_url, billing_email, collaborators, created_at, description, email, htmlurl, id, location, login, name, node_id, owned_private_repos, public_repos, total_private_repos, two_factor_requirement_enabled, updated_at" - usersCols = "avatar_url, bio, company, created_at, email, followers, following, hireable, htmlurl, id, location, login, name, node_id, owned_private_repos, private_gists, public_gists, public_repos, site_admin, total_private_repos, updated_at" - repositoriesCols = "allow_merge_commit, allow_rebase_merge, allow_squash_merge, archived, clone_url, created_at, default_branch, description, disabled, fork, forks_count, full_name, has_issues, has_wiki, homepage, htmlurl, id, language, mirror_url, name, node_id, open_issues_count, owner_id, owner_login, owner_type, private, pushed_at, sshurl, stargazers_count, topics, updated_at, watchers_count" + organizationsCols = "avatar_url, collaborators, created_at, description, email, htmlurl, id, login, name, node_id, owned_private_repos, public_repos, total_private_repos, updated_at" + usersCols = "avatar_url, bio, company, created_at, email, followers, following, hireable, htmlurl, id, location, login, name, node_id, owned_private_repos, private_gists, public_gists, public_repos, total_private_repos, updated_at" + repositoriesCols = "allow_merge_commit, allow_rebase_merge, allow_squash_merge, archived, created_at, default_branch, description, disabled, fork, forks_count, full_name, has_issues, has_wiki, homepage, htmlurl, id, language, name, node_id, open_issues_count, owner_id, owner_login, owner_type, private, pushed_at, sshurl, stargazers_count, topics, updated_at, watchers_count" issuesCols = "assignees, body, closed_at, closed_by_id, closed_by_login, comments, created_at, htmlurl, id, labels, locked, milestone_id, milestone_title, node_id, number, repository_name, repository_owner, state, title, updated_at, user_id, user_login" issueCommentsCols = "author_association, body, created_at, htmlurl, id, issue_number, node_id, repository_name, repository_owner, updated_at, user_id, user_login" pullRequestsCol = "additions, assignees, author_association, base_ref, base_repository_name, base_repository_owner, base_sha, base_user, body, changed_files, closed_at, comments, commits, created_at, deletions, head_ref, head_repository_name, head_repository_owner, head_sha, head_user, htmlurl, id, labels, maintainer_can_modify, merge_commit_sha, mergeable, merged, merged_at, merged_by_id, merged_by_login, milestone_id, milestone_title, node_id, number, repository_name, repository_owner, review_comments, state, title, updated_at, user_id, user_login" @@ -144,10 +144,10 @@ func (s *DB) SaveOrganization(ctx context.Context, organization *graphql.Organiz `INSERT INTO organizations_versioned (sum256, versions, %s) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, - $15, $16, $17, $18, $19) + $15, $16) ON CONFLICT (sum256) DO UPDATE - SET versions = array_append(organizations_versioned.versions, $20)`, + SET versions = array_append(organizations_versioned.versions, $17)`, organizationsCols) st := fmt.Sprintf("%+v", organization) @@ -158,26 +158,20 @@ func (s *DB) SaveOrganization(ctx context.Context, organization *graphql.Organiz hashString, pq.Array([]int{s.v}), - organization.AvatarUrl, // avatar_url text, - // TODO - "", // organization.OrganizationBillingEmail, // billing_email text, + organization.AvatarURL, // avatar_url text, organization.MembersWithRole.TotalCount, // collaborators bigint, organization.CreatedAt, // created_at timestamptz, organization.Description, // description text, organization.Email, // email text, - organization.Url, // htmlurl text, - organization.DatabaseId, // id bigint, - organization.Location, // location text, + organization.URL, // htmlurl text, + organization.DatabaseID, // id bigint, organization.Login, // login text, organization.Name, // name text, - organization.Id, // node_id text, + organization.ID, // node_id text, organization.OwnedPrivateRepos.TotalCount, // owned_private_repos bigint, organization.PublicRepos.TotalCount, // public_repos bigint, organization.TotalPrivateRepos.TotalCount, // total_private_repos bigint, - // TODO: requires admin privileges - //organization.RequiresTwoFactorAuthentication, // two_factor_requirement_enabled boolean, - false, - organization.UpdatedAt, // updated_at timestamptz, + organization.UpdatedAt, // updated_at timestamptz, s.v, ) @@ -193,10 +187,10 @@ func (s *DB) SaveUser(ctx context.Context, user *graphql.UserExtended) error { `INSERT INTO users_versioned (sum256, versions, %s) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, - $15, $16, $17, $18, $19, $20, $21, $22, $23) + $15, $16, $17, $18, $19, $20, $21, $22) ON CONFLICT (sum256) DO UPDATE - SET versions = array_append(users_versioned.versions, $24)`, + SET versions = array_append(users_versioned.versions, $23)`, usersCols) st := fmt.Sprintf("%+v", user) @@ -207,7 +201,7 @@ func (s *DB) SaveUser(ctx context.Context, user *graphql.UserExtended) error { hashString, pq.Array([]int{s.v}), - user.AvatarUrl, // avatar_url text, + user.AvatarURL, // avatar_url text, user.Bio, // bio text, user.Company, // company text, user.CreatedAt, // created_at timestamptz, @@ -216,18 +210,17 @@ func (s *DB) SaveUser(ctx context.Context, user *graphql.UserExtended) error { user.Followers.TotalCount, // followers bigint, user.Following.TotalCount, // following bigint, user.IsHireable, // hireable boolean, - user.Url, // htmlurl text, - user.DatabaseId, // id bigint, + user.URL, // htmlurl text, + user.DatabaseID, // id bigint, user.Location, // location text, user.Login, // login text, user.Name, // name text, - user.Id, // node_id text, + user.ID, // node_id text, user.OwnedPrivateRepos.TotalCount, // owned_private_repos bigint, // TODO: gists makes the server return: You don't have permission to see gists. 0, // private_gists bigint, 0, // public_gists bigint, user.PublicRepos.TotalCount, // public_repos bigint, - user.IsSiteAdmin, // site_admin boolean, user.TotalPrivateRepos.TotalCount, // total_private_repos bigint, user.UpdatedAt, // updated_at timestamptz, @@ -246,10 +239,10 @@ func (s *DB) SaveRepository(ctx context.Context, repository *graphql.RepositoryF (sum256, versions, %s) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, - $30, $31, $32, $33, $34) + $30, $31, $32) ON CONFLICT (sum256) DO UPDATE - SET versions = array_append(repositories_versioned.versions, $35)`, + SET versions = array_append(repositories_versioned.versions, $33)`, repositoriesCols) st := fmt.Sprintf("%+v %v", repository, topics) @@ -264,7 +257,6 @@ func (s *DB) SaveRepository(ctx context.Context, repository *graphql.RepositoryF repository.RebaseMergeAllowed, // allow_rebase_merge boolean repository.SquashMergeAllowed, // allow_squash_merge boolean repository.IsArchived, // archived boolean - repository.Url, // clone_url text repository.CreatedAt, // created_at timestamptz repository.DefaultBranchRef.Name, // default_branch text repository.Description, // description text @@ -274,20 +266,19 @@ func (s *DB) SaveRepository(ctx context.Context, repository *graphql.RepositoryF repository.NameWithOwner, // full_name text repository.HasIssuesEnabled, // has_issues boolean repository.HasWikiEnabled, // has_wiki boolean - repository.HomepageUrl, // homepage text - repository.Url, // htmlurl text - repository.DatabaseId, // id bigint, + repository.HomepageURL, // homepage text + repository.URL, // htmlurl text + repository.DatabaseID, // id bigint, repository.PrimaryLanguage.Name, // language text - repository.MirrorUrl, // mirror_url text repository.Name, // name text - repository.Id, // node_id text + repository.ID, // node_id text repository.OpenIssues.TotalCount, // open_issues_count bigint repoOwnerID(repository), // owner_id bigint NOT NULL, repository.Owner.Login, // owner_login text NOT NULL, repository.Owner.Typename, // owner_type text NOT NULL repository.IsPrivate, // private boolean repository.PushedAt, // pushed_at timestamptz - repository.SshUrl, // sshurl text + repository.SSHURL, // sshurl text repository.Stargazers.TotalCount, // stargazers_count bigint pq.Array(topics), // topics text[] NOT NULL repository.UpdatedAt, // updated_at timestamptz @@ -305,9 +296,9 @@ func (s *DB) SaveRepository(ctx context.Context, repository *graphql.RepositoryF func repoOwnerID(repository *graphql.RepositoryFields) int { switch repository.Owner.Typename { case "Orgazation": - return repository.Owner.Organization.DatabaseId + return repository.Owner.Organization.DatabaseID case "User": - return repository.Owner.User.DatabaseId + return repository.Owner.User.DatabaseID default: return 0 } @@ -328,11 +319,11 @@ func (s *DB) SaveIssue(ctx context.Context, repositoryOwner, repositoryName stri hash := sha256.Sum256([]byte(st)) hashString := fmt.Sprintf("%x", hash) - closedById := 0 + closedByID := 0 closedByLogin := "" if len(issue.ClosedBy.Nodes) > 0 { - closedById = issue.ClosedBy.Nodes[0].ClosedEvent.Actor.DatabaseId + closedByID = issue.ClosedBy.Nodes[0].ClosedEvent.Actor.DatabaseID closedByLogin = issue.ClosedBy.Nodes[0].ClosedEvent.Actor.Login } @@ -343,24 +334,24 @@ func (s *DB) SaveIssue(ctx context.Context, repositoryOwner, repositoryName stri pq.Array(assignees), // assignees text[] NOT NULL, issue.Body, // body text, issue.ClosedAt, // closed_at timestamptz, - closedById, // closed_by_id bigint NOT NULL + closedByID, // closed_by_id bigint NOT NULL closedByLogin, // closed_by_login text NOT NULL, issue.Comments.TotalCount, // comments bigint, issue.CreatedAt, // created_at timestamptz, - issue.Url, // htmlurl text, - issue.DatabaseId, // id bigint, + issue.URL, // htmlurl text, + issue.DatabaseID, // id bigint, pq.Array(labels), // labels text[] NOT NULL, issue.Locked, // locked boolean, - issue.Milestone.Id, // milestone_id text NOT NULL, + issue.Milestone.ID, // milestone_id text NOT NULL, issue.Milestone.Title, // milestone_title text NOT NULL, - issue.Id, // node_id text, + issue.ID, // node_id text, issue.Number, // number bigint, repositoryName, // repository_name text NOT NULL, repositoryOwner, // repository_owner text NOT NULL, issue.State, // state text, issue.Title, // title text, issue.UpdatedAt, // updated_at timestamptz, - issue.Author.User.DatabaseId, // user_id bigint NOT NULL, + issue.Author.User.DatabaseID, // user_id bigint NOT NULL, issue.Author.Login, // user_login text NOT NULL, s.v, @@ -392,14 +383,14 @@ func (s *DB) SaveIssueComment(ctx context.Context, repositoryOwner, repositoryNa comment.AuthorAssociation, // author_association text, comment.Body, // body text, comment.CreatedAt, // created_at timestamptz, - comment.Url, // htmlurl text, - comment.DatabaseId, // id bigint, + comment.URL, // htmlurl text, + comment.DatabaseID, // id bigint, issueNumber, // issue_number bigint NOT NULL, - comment.Id, // node_id text, + comment.ID, // node_id text, repositoryName, // repository_name text NOT NULL, repositoryOwner, // repository_owner text NOT NULL, comment.UpdatedAt, // updated_at timestamptz, - comment.Author.User.DatabaseId, // user_id bigint NOT NULL, + comment.Author.User.DatabaseID, // user_id bigint NOT NULL, comment.Author.Login, // user_login text NOT NULL, s.v, @@ -451,19 +442,19 @@ func (s *DB) SavePullRequest(ctx context.Context, repositoryOwner, repositoryNam pr.HeadRef.Repository.Owner.Login, // head_repository_owner text NOT NULL, pr.HeadRef.Target.Oid, // head_sha text NOT NULL, pr.HeadRef.Target.Commit.Author.User.Login, // head_user text NOT NULL, - pr.Url, // htmlurl text, - pr.DatabaseId, // id bigint, + pr.URL, // htmlurl text, + pr.DatabaseID, // id bigint, pq.Array(labels), // labels text[] NOT NULL, pr.MaintainerCanModify, // maintainer_can_modify boolean, pr.MergeCommit.Oid, // merge_commit_sha text, pr.Mergeable == "MERGEABLE", // mergeable boolean, pr.Merged, // merged boolean, pr.MergedAt, // merged_at timestamptz, - pr.MergedBy.DatabaseId, // merged_by_id bigint NOT NULL, + pr.MergedBy.DatabaseID, // merged_by_id bigint NOT NULL, pr.MergedBy.Login, // merged_by_login text NOT NULL, - pr.Milestone.Id, // milestone_id text NOT NULL, + pr.Milestone.ID, // milestone_id text NOT NULL, pr.Milestone.Title, // milestone_title text NOT NULL, - pr.Id, // node_id text, + pr.ID, // node_id text, pr.Number, // number bigint, repositoryName, // repository_name text NOT NULL, repositoryOwner, // repository_owner text NOT NULL, @@ -471,7 +462,7 @@ func (s *DB) SavePullRequest(ctx context.Context, repositoryOwner, repositoryNam pr.State, // state text, pr.Title, // title text, pr.UpdatedAt, // updated_at timestamptz, - pr.Author.DatabaseId, // user_id bigint NOT NULL, + pr.Author.DatabaseID, // user_id bigint NOT NULL, pr.Author.Login, // user_login text NOT NULL, s.v, @@ -507,15 +498,15 @@ func (s *DB) SavePullRequestReview(ctx context.Context, repositoryOwner, reposit review.Body, // body text, review.Commit.Oid, // commit_id text, - review.Url, // htmlurl text, - review.DatabaseId, // id bigint, - review.Id, // node_id text, + review.URL, // htmlurl text, + review.DatabaseID, // id bigint, + review.ID, // node_id text, pullRequestNumber, // pull_request_number bigint NOT NULL, repositoryName, // repository_name text NOT NULL, repositoryOwner, // repository_owner text NOT NULL, review.State, // state text, review.SubmittedAt, // submitted_at timestamptz, - review.Author.User.DatabaseId, // user_id bigint NOT NULL, + review.Author.User.DatabaseID, // user_id bigint NOT NULL, review.Author.Login, // user_login text NOT NULL, s.v, @@ -550,11 +541,11 @@ func (s *DB) SavePullRequestReviewComment(ctx context.Context, repositoryOwner, comment.Commit.Oid, // commit_id text, comment.CreatedAt, // created_at timestamptz, comment.DiffHunk, // diff_hunk text, - comment.Url, // htmlurl text, - comment.DatabaseId, // id bigint, + comment.URL, // htmlurl text, + comment.DatabaseID, // id bigint, // TODO 0, // in_reply_to bigint, - comment.Id, // node_id text, + comment.ID, // node_id text, comment.OriginalCommit.Oid, // original_commit_id text, comment.OriginalPosition, // original_position bigint, comment.Path, // path text, @@ -564,7 +555,7 @@ func (s *DB) SavePullRequestReviewComment(ctx context.Context, repositoryOwner, repositoryName, // repository_name text NOT NULL, repositoryOwner, // repository_owner text NOT NULL, comment.UpdatedAt, // updated_at timestamptz, - comment.Author.DatabaseId, // user_id bigint NOT NULL, + comment.Author.DatabaseID, // user_id bigint NOT NULL, comment.Author.Login, // user_login text NOT NULL, s.v,