Documentation ¶
Index ¶
- Variables
- func Compute(db *gorm.DB) error
- func PullAndCompute(githubToken, gitlabToken string, db *gorm.DB, t Targets) error
- type Account
- type Base
- type Feature
- type Issue
- func (i Issue) GetRelativeURL(target string) string
- func (i Issue) IsClosed() bool
- func (i Issue) IsReady() bool
- func (i Issue) MatchesWithATarget(targets Targets) bool
- func (i *Issue) Number() string
- func (i *Issue) Path() string
- func (i *Issue) PostLoad()
- func (i *Issue) Render(w http.ResponseWriter, r *http.Request) error
- func (i Issue) String() string
- func (i Issue) ToRecord(cache airtabledb.DB) airtabledb.Record
- type Issues
- type Label
- type Milestone
- type Provider
- type ProviderDriver
- type Repository
- type Target
- type Targets
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var AllModels = []interface{}{ Repository{}, Provider{}, Milestone{}, Issue{}, Label{}, Account{}, }
Functions ¶
Types ¶
type Account ¶
type Account struct { Base // base fields URL string `json:"url"` Login string `json:"login"` FullName string `json:"fullname"` Type string `json:"type"` Bio string `json:"bio"` Location string `json:"location"` Company string `json:"company"` Blog string `json:"blog"` Email string `json:"email"` AvatarURL string `json:"avatar-url"` // relationships Provider *Provider `json:"provider"` ProviderID string `json:"provider-id"` }
func (Account) ToRecord ¶
func (a Account) ToRecord(cache airtabledb.DB) airtabledb.Record
type Base ¶
type Feature ¶
type Feature interface { String() string GetID() string ToRecord(airtabledb.DB) airtabledb.Record }
type Issue ¶
type Issue struct { Base // base fields URL string `json:"url"` CompletedAt time.Time `json:"completed-at"` Title string `json:"title"` State string `json:"state"` Body string `json:"body"` IsPR bool `json:"is-pr"` IsLocked bool `json:"is-locked"` Comments int `json:"comments"` Upvotes int `json:"upvotes"` Downvotes int `json:"downvotes"` IsOrphan bool `json:"is-orphan"` IsHidden bool `json:"is-hidden"` Weight int `json:"weight"` IsEpic bool `json:"is-epic"` HasEpic bool `json:"has-epic"` // relationships Repository *Repository `json:"repository"` RepositoryID string `json:"repository_id"` Milestone *Milestone `json:"milestone"` MilestoneID string `json:"milestone_id"` Author *Account `json:"author"` AuthorID string `json:"author_id"` Labels []*Label `gorm:"many2many:issue_labels" json:"labels"` Assignees []*Account `gorm:"many2many:issue_assignees" json:"assignees"` Parents []*Issue `json:"-" gorm:"many2many:issue_parents;association_jointable_foreignkey:parent_id"` Children []*Issue `json:"-" gorm:"many2many:issue_children;association_jointable_foreignkey:child_id"` Duplicates []*Issue `json:"-" gorm:"many2many:issue_duplicates;association_jointable_foreignkey:duplicate_id"` // internal ChildIDs []string `json:"child_ids" gorm:"-"` ParentIDs []string `json:"parent_ids" gorm:"-"` DuplicateIDs []string `json:"duplicate_ids" gorm:"-"` }
func (Issue) GetRelativeURL ¶
Example ¶
issue := Issue{ URL: "https://github.com/moul/depviz/issues/42", Repository: &Repository{ URL: "https://github.com/moul/depviz", Provider: &Provider{ URL: "https://github.com/", }, }, } for _, target := range []string{ "#43", "moul/depviz#44", "github.com/moul/depviz/issues/45", "https://github.com/moul/depviz/issues/46", "test/test#47", "github.com/test/test/issues/48", "https://github.com/test/test/issues/49", "gitlab.com/moul/depviz/issues/50", "https://gitlab.com/moul/depviz/issues/51", "gitlab.com/test2/issues/52", "gitlab.com/test2/test3/test4/issues/53", } { fmt.Printf("%-42s -> %s\n", target, issue.GetRelativeURL(target)) } issue = Issue{ URL: "https://gitlab.com/moul/depviz/issues/42", Repository: &Repository{ URL: "https://gitlab.com/moul/depviz", Provider: &Provider{ URL: "https://gitlab.com/", }, }, } for _, target := range []string{ "#43", "moul/depviz#44", "gitlab.com/moul/depviz/issues/45", "https://gitlab.com/moul/depviz/issues/46", "test/test#47", "gitlab.com/test/test/issues/48", "https://gitlab.com/test/test/issues/49", "github.com/moul/depviz/issues/50", "https://github.com/moul/depviz/issues/51", "github.com/test2/issues/52", "github.com/test2/test3/test4/issues/53", } { fmt.Printf("%-42s -> %s\n", target, issue.GetRelativeURL(target)) }
Output: #43 -> https://github.com/moul/depviz/issues/43 moul/depviz#44 -> https://github.com/moul/depviz/issues/44 github.com/moul/depviz/issues/45 -> https://github.com/moul/depviz/issues/45 https://github.com/moul/depviz/issues/46 -> https://github.com/moul/depviz/issues/46 test/test#47 -> https://github.com/test/test/issues/47 github.com/test/test/issues/48 -> https://github.com/test/test/issues/48 https://github.com/test/test/issues/49 -> https://github.com/test/test/issues/49 gitlab.com/moul/depviz/issues/50 -> https://gitlab.com/moul/depviz/issues/50 https://gitlab.com/moul/depviz/issues/51 -> https://gitlab.com/moul/depviz/issues/51 gitlab.com/test2/issues/52 -> https://gitlab.com/test2/issues/52 gitlab.com/test2/test3/test4/issues/53 -> https://gitlab.com/test2/test3/test4/issues/53 #43 -> https://gitlab.com/moul/depviz/issues/43 moul/depviz#44 -> https://gitlab.com/moul/depviz/issues/44 gitlab.com/moul/depviz/issues/45 -> https://gitlab.com/moul/depviz/issues/45 https://gitlab.com/moul/depviz/issues/46 -> https://gitlab.com/moul/depviz/issues/46 test/test#47 -> https://gitlab.com/test/test/issues/47 gitlab.com/test/test/issues/48 -> https://gitlab.com/test/test/issues/48 https://gitlab.com/test/test/issues/49 -> https://gitlab.com/test/test/issues/49 github.com/moul/depviz/issues/50 -> https://github.com/moul/depviz/issues/50 https://github.com/moul/depviz/issues/51 -> https://github.com/moul/depviz/issues/51 github.com/test2/issues/52 -> https://github.com/test2/issues/52 github.com/test2/test3/test4/issues/53 -> https://github.com/test2/test3/test4/issues/53
func (Issue) MatchesWithATarget ¶
func (Issue) ToRecord ¶
func (i Issue) ToRecord(cache airtabledb.DB) airtabledb.Record
type Issues ¶
type Issues []*Issue
func (Issues) FilterByTargets ¶
type Label ¶
type Label struct { Base // base fields URL string `json:"url"` Name string `json:"name"` Color string `json:"color"` Description string `json:"description"` }
func (Label) ToRecord ¶
func (l Label) ToRecord(cache airtabledb.DB) airtabledb.Record
type Milestone ¶
type Milestone struct { Base // base fields URL string `json:"url"` Title string `json:"title"` Description string `json:"description"` ClosedAt time.Time `json:"closed-at"` DueOn time.Time `json:"due-on"` // relationships Creator *Account `json:"creator"` CreatorID string `json:"creator-id"` Repository *Repository `json:"repository"` RepositoryID string `json:"repository-id"` }
func (Milestone) ToRecord ¶
func (m Milestone) ToRecord(cache airtabledb.DB) airtabledb.Record
type Provider ¶
type Provider struct { Base // base fields URL string `json:"url"` Driver string `json:"driver"` // github, gitlab, unknown }
func (Provider) ToRecord ¶
func (p Provider) ToRecord(cache airtabledb.DB) airtabledb.Record
type ProviderDriver ¶
type ProviderDriver string
const ( UnknownProviderDriver ProviderDriver = "unknown" GithubDriver ProviderDriver = "github" GitlabDriver ProviderDriver = "gitlab" )
type Repository ¶
type Repository struct { Base // base fields URL string `json:"url"` Title string `json:"name"` Description string `json:"description"` Homepage string `json:"homepage"` PushedAt time.Time `json:"pushed-at"` IsFork bool `json:"fork"` // relationships Provider *Provider `json:"provider"` ProviderID string `json:"provider-id"` Owner *Account `json:"owner"` OwnerID string `json:"owner-id"` }
func (Repository) String ¶
func (r Repository) String() string
func (Repository) ToRecord ¶
func (r Repository) ToRecord(cache airtabledb.DB) airtabledb.Record
type Target ¶
type Target string
func (Target) Driver ¶
func (t Target) Driver() ProviderDriver
func (Target) ProjectURL ¶
func (Target) ProviderURL ¶
type Targets ¶
type Targets []Target
func ParseTargets ¶
Example ¶
targets, _ := ParseTargets([]string{ "moul/project1", "moul/project2#42", "github.com/moul/project3", "https://github.com/moul/project4/issues/42", "https://gitlab.com/moul/project5#42", "gitlab.com/moul/project6", }) for _, target := range targets { fmt.Printf( "target=%q canonical=%q project=%q namespace=%q providerurl=%q driver=%q path=%q projecturl=%q issue=%q\n", target, target.Canonical(), target.Project(), target.Namespace(), target.ProviderURL(), target.Driver(), target.Path(), target.ProjectURL(), target.Issue(), ) }
Output: target="https://github.com/moul/project1" canonical="https://github.com/moul/project1" project="project1" namespace="moul" providerurl="https://github.com" driver="github" path="moul/project1" projecturl="https://github.com/moul/project1" issue="" target="https://github.com/moul/project2/issues/42" canonical="https://github.com/moul/project2/issues/42" project="project2" namespace="moul" providerurl="https://github.com" driver="github" path="moul/project2" projecturl="https://github.com/moul/project2" issue="42" target="https://github.com/moul/project3" canonical="https://github.com/moul/project3" project="project3" namespace="moul" providerurl="https://github.com" driver="github" path="moul/project3" projecturl="https://github.com/moul/project3" issue="" target="https://github.com/moul/project4/issues/42" canonical="https://github.com/moul/project4/issues/42" project="project4" namespace="moul" providerurl="https://github.com" driver="github" path="moul/project4" projecturl="https://github.com/moul/project4" issue="42" target="https://gitlab.com/moul/project5/issues/42" canonical="https://gitlab.com/moul/project5/issues/42" project="project5" namespace="moul" providerurl="https://gitlab.com" driver="gitlab" path="moul/project5" projecturl="https://gitlab.com/moul/project5" issue="42" target="https://gitlab.com/moul/project6" canonical="https://gitlab.com/moul/project6" project="project6" namespace="moul" providerurl="https://gitlab.com" driver="gitlab" path="moul/project6" projecturl="https://gitlab.com/moul/project6" issue=""
func (Targets) UniqueProjects ¶
Example ¶
targets, _ := ParseTargets([]string{ "moul/project1", "moul/project2#42", "moul/project2", "github.com/moul/project1", "https://github.com/moul/project2/issues/42", "https://gitlab.com/moul/project1#42", "https://gitlab.com/moul/project1", "https://gitlab.com/moul/project2", "gitlab.com/moul/project1", }) for _, target := range targets.UniqueProjects() { fmt.Println(target.Canonical()) }
Output: https://github.com/moul/project1 https://github.com/moul/project2 https://gitlab.com/moul/project1 https://gitlab.com/moul/project2
Click to show internal directories.
Click to hide internal directories.