Documentation ¶
Overview ¶
Package github provides definitions and methods for structs used for handling Github data from BigQuery and Cloud SQL. Methods for making authenticated requests to the GitHub API are implemented in this package
Index ¶
- Variables
- func API(ctx context.Context, path string, params ...string) (*http.Response, error)
- func UpdateRepo(ctx context.Context, r string) error
- type Comment
- type CommentFetcher
- type EmailPayload
- type EmailPreference
- type Frequency
- type Issue
- type IssueFetcher
- type Notification
- type Options
- type Payload
- type Repo
- type Subscription
- type User
- func (u *User) Add() error
- func (u User) AddNotification(ctx context.Context, email string, emailType Frequency, data []Payload)
- func (u User) GetNotifications(emailType Frequency) ([]Notification, error)
- func (u User) GetRepos(repos ...string) ([]Repo, error)
- func (u User) GetSubscriptions(repos ...string) ([]Subscription, error)
- func (u *User) IsNew() (User, bool)
- func (u User) Remove() error
- func (u *User) Subscribe(repo string, pref EmailPreference, argv ...string) error
- func (u *User) Unsubscribe(repos ...string) error
- func (u *User) UnsubscribeAll() error
- func (u *User) Update() error
- func (u *User) UpdateSubscription(repo string, s *Subscription) error
Constants ¶
This section is empty.
Variables ¶
var (
DB *gorm.DB
)
DB exposes the connection to the backend database
Functions ¶
Types ¶
type Comment ¶
type Comment struct { ID int64 `gorm:"primary_key"` // Github's unique ID for comments created IssueID string // Parent Issue's ID for the comment Body string // Comment's body Author string // author's github login name Created time.Time // timestamp with date of creation UpdatedAt time.Time // timestamp with last update Repo string // API url for the Comment's parent repo URL string // https url for the comment on github.com }
Comment holds metadata for comments on GitHub Issues
type CommentFetcher ¶
type CommentFetcher struct { Opts Options // contains filtered or unexported fields }
CommentFetcher uses information stored to query the githubarchive dataset for comments
type EmailPayload ¶
EmailPayload is the type that contains email data for one Email to be sent
func FetchData ¶
func FetchData(c context.Context, subscriptions []Subscription, emailType Frequency) ([]EmailPayload, error)
FetchData constructs bigquery requests for fetching appropriate data for email notifications
type EmailPreference ¶
type EmailPreference struct { SubscriptionID uint `gorm:"unique;index;not null;"` IssueOpen Frequency `gorm:"type:INT;" sql:"DEFAULT:1"` IssueClose Frequency `gorm:"type:INT;" sql:"DEFAULT:1"` IssueReopen Frequency `gorm:"type:INT;" sql:"DEFAULT:1"` NewComment Frequency `gorm:"type:INT;" sql:"DEFAULT:1"` NoComment Frequency `gorm:"type:INT;" sql:"DEFAULT:1"` }
EmailPreference stores frequency for various types of notifications
func NewPreference ¶
func NewPreference() EmailPreference
NewPreference returns a default email frequency for all types set to daily
type Frequency ¶
type Frequency int
Frequency is used for tracking notification frequency preferences
type Issue ¶
type Issue struct { ID int64 `gorm:"primary_key"` // Github's unique ID for issues created Number int // issue number that is specific to a repository Title string // title for the issue Author string // author's github login name Created time.Time // timestamp with date of creation UpdatedAt time.Time // timestamp with last update Repo string // API url for the issue's parent repo URL string // https url for the issue on github.com }
Issue holds metadata for GitHub Issues
type IssueFetcher ¶
type IssueFetcher struct { Opts Options // contains filtered or unexported fields }
IssueFetcher uses information stored to query the githubarchive dataset for issues
type Notification ¶
type Notification struct { ID uint `gorm:"primary_key;AUTO_INCREMENT"` UserID uint64 `gorm:"index;not null;"` Email string `gorm:"not null;"` Type Frequency `gorm:"not null;"` Repos string `gorm:"not null;type:TEXT;"` CreatedAt time.Time }
Notification stores logging information of outgoing notifications
type Options ¶
type Options struct { Tables []string // To override the default tables - when extending the query for different dates Repositories []string // To set repositories to fetch Issues From Kind []string // To set the Kinds of Event to select - eg "opened", "closed",etc Order []string // To override default fields for use in OrderBy Clause Limit uint64 // To override default limit value Conditions []string // To override all conditions for the Query }
Options allows for additional configuration of the query
type Payload ¶
type Payload struct { RepoName string OpenIssues []Issue ClosedIssues []Issue Comments []Comment NoComment bool NoCommentSince time.Time }
Payload is the type that contains email data for one repo
type Repo ¶
type Repo struct { ID uint64 `gorm:"primary_key;AUTO_INCREMENT"` Name string `gorm:"index;not null;"` IssuesOpen uint64 `gorm:"type:INT;" ` UpdatedAt time.Time }
Repo stores open issue count for repositories
type Subscription ¶
type Subscription struct { ID uint `gorm:"primary_key;AUTO_INCREMENT"` UserID uint64 `gorm:"index;not null;"` Repo string `gorm:"index;not null;"` DefaultEmail string `gorm:"not null;"` EmailPreference EmailPreference `gorm:"ForeignKey:SubscriptionID"` LastNotificationID uint64 // Last notification’s ID for sending reminders if needed }
Subscription stores information that relates a repo with a user's watch list
type User ¶
type User struct { ID uint64 `gorm:"primary_key;"` // Unique Identifier for user Entity FireKey string `gorm:"unique_index;"` // User's firebase UID Login string `gorm:"unique_index;"` // Github ID for the user Email string `gorm:"unique_index;"` // User's default email Subscriptions []Subscription `gorm:"ForeignKey:UserID"` CreatedAt time.Time }
User stores basic user data
func FindUserByLogin ¶
FindUserByLogin retrieves a user object by their Github ID
func (User) AddNotification ¶
func (u User) AddNotification( ctx context.Context, email string, emailType Frequency, data []Payload)
AddNotification saves notification information for the user
func (User) GetNotifications ¶
func (u User) GetNotifications(emailType Frequency) ([]Notification, error)
GetNotifications returns all notifications sent to a user if emailType is 0 or all notifications of a particular emailType (daily/weekly/monthly)
func (User) GetRepos ¶
GetRepos returns data for passed repos If no repos are passed, it returns the entire list of repo data stored for a user
func (User) GetSubscriptions ¶
func (u User) GetSubscriptions(repos ...string) ([]Subscription, error)
GetSubscriptions returns all the subscriptions that match passed repos for a user If no repos are passed, it returns the entire list of subscriptions
func (*User) Subscribe ¶
func (u *User) Subscribe(repo string, pref EmailPreference, argv ...string) error
Subscribe adds a subscription to a user
Optional argument is DefaultEmail
func (*User) Unsubscribe ¶
Unsubscribe removes a subscription from a user
func (*User) UnsubscribeAll ¶
UnsubscribeAll removes all subscriptions for a user
func (*User) Update ¶
Update updates the user record for the calling object or creates a new record in the DB
func (*User) UpdateSubscription ¶
func (u *User) UpdateSubscription(repo string, s *Subscription) error
UpdateSubscription updates a user's subscription preferences
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package bq provides definitions and methods for structs used for querying data from the a dataset on BigQuery
|
Package bq provides definitions and methods for structs used for querying data from the a dataset on BigQuery |
Package db provides types and methods database operations.
|
Package db provides types and methods database operations. |