Skip to content

Commit

Permalink
optimize: add owner and name field for issue and pr
Browse files Browse the repository at this point in the history
  • Loading branch information
justlorain committed Jun 25, 2024
1 parent 0660b69 commit 54b10bf
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cron/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,8 @@ func CreateRepoData(ctx context.Context, db *gorm.DB, rd *RepoData) error {
Author: issue.Author.Login,
AuthorNodeID: issue.Author.User.ID,
RepoNodeID: issue.Repository.ID,
RepoOwner: rd.Owner,
RepoName: rd.Name,
Number: issue.Number,
State: issue.State,
IssueCreatedAt: issue.CreatedAt,
Expand Down Expand Up @@ -435,6 +437,8 @@ func CreateRepoData(ctx context.Context, db *gorm.DB, rd *RepoData) error {
Author: pr.Author.Login,
AuthorNodeID: pr.Author.User.ID,
RepoNodeID: pr.Repository.ID,
RepoOwner: rd.Owner,
RepoName: rd.Name,
Number: pr.Number,
State: pr.State,
PRCreatedAt: pr.CreatedAt,
Expand Down Expand Up @@ -514,6 +518,8 @@ func UpdateRepoData(ctx context.Context, db *gorm.DB, rd *RepoData) error {
Author: issue.Author.Login,
AuthorNodeID: issue.Author.User.ID,
RepoNodeID: issue.Repository.ID,
RepoOwner: rd.Owner,
RepoName: rd.Name,
Number: issue.Number,
State: issue.State,
IssueCreatedAt: issue.CreatedAt,
Expand Down Expand Up @@ -657,6 +663,8 @@ func UpdateRepoData(ctx context.Context, db *gorm.DB, rd *RepoData) error {
Author: pr.Author.Login,
AuthorNodeID: pr.Author.User.ID,
RepoNodeID: pr.Repository.ID,
RepoOwner: rd.Owner,
RepoName: rd.Name,
Number: pr.Number,
State: pr.State,
PRCreatedAt: pr.CreatedAt,
Expand Down
2 changes: 2 additions & 0 deletions model/contributor.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import "gorm.io/gorm"
// Contributor one to many PullRequest (Author)
// Contributor many to many Issue (Assignees)
// Contributor many to many PullRequest (Assignees)
//
// NOTE: create on update
type Contributor struct {
gorm.Model

Expand Down
3 changes: 3 additions & 0 deletions model/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ package model

import "gorm.io/gorm"

// Group
//
// NOTE: create on update
type Group struct {
gorm.Model

Expand Down
2 changes: 2 additions & 0 deletions model/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ type Issue struct {
Author string
AuthorNodeID string
RepoNodeID string
RepoOwner string
RepoName string
Number int

// OPEN | CLOSED
Expand Down
2 changes: 2 additions & 0 deletions model/organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ package model
import "gorm.io/gorm"

// Organization one to many Repository
//
// NOTE: create on update
type Organization struct {
gorm.Model

Expand Down
2 changes: 2 additions & 0 deletions model/pullrequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ type PullRequest struct {
Author string
AuthorNodeID string
RepoNodeID string
RepoOwner string
RepoName string
Number int

// CLOSED | MERGED | OPEN
Expand Down
2 changes: 2 additions & 0 deletions model/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ package model
import "gorm.io/gorm"

// Repository one to many Contributor
//
// NOTE: create on update
type Repository struct {
gorm.Model

Expand Down
1 change: 1 addition & 0 deletions storage/sql/init.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
-- TODO: need update
CREATE TABLE `cursors`
(
`id` bigint unsigned AUTO_INCREMENT,
Expand Down

0 comments on commit 54b10bf

Please sign in to comment.