data

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 1, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EventTypes is a list of event types to import
	EventTypePR           string = "pr"
	EventTypePRReview     string = "pr_review"
	EventTypeIssue        string = "issue"
	EventTypeIssueComment string = "issue_comment"
	EventTypeFork         string = "fork"

	EventAgeMonthsDefault = 6
)
View Source
const (
	DataFileName string = "data.db"
)

Variables

View Source
var (
	UpdatableProperties = []string{
		"entity",
	}
)

Functions

func CleanEntities

func CleanEntities(db *sql.DB) error

func Contains added in v0.3.9

func Contains[T comparable](list []T, val T) bool

Contains checks for val in list

func GetCNCFEntityAffiliations

func GetCNCFEntityAffiliations() (map[string]*CNCFDeveloper, error)

func GetDB

func GetDB(path string) (*sql.DB, error)

func GetDataState

func GetDataState(db *sql.DB) (map[string]int64, error)

GetDataState returns the current state of the database.

func GetDeveloperUsernames

func GetDeveloperUsernames(db *sql.DB) ([]string, error)

func GetNoFullnameDeveloperUsernames

func GetNoFullnameDeveloperUsernames(db *sql.DB) ([]string, error)

func GetOrgRepoNames added in v0.3.2

func GetOrgRepoNames(ctx context.Context, client *http.Client, org string) ([]string, error)

func ImportEvents

func ImportEvents(dbPath, token, owner, repo string, months int) (map[string]int, error)

ImportEvents imports events from GitHub for a given org/repo combination.

func Init

func Init(dbFilePath string) error

Init initializes the database for a given name.

func SaveDevelopers

func SaveDevelopers(db *sql.DB, devs []*Developer) error

func SaveState

func SaveState(db *sql.DB, query, org, repo string, state *State) error

func UpdateDeveloper

func UpdateDeveloper(ctx context.Context, db *sql.DB, client *http.Client, username string, cDev *CNCFDeveloper) error

func UpdateDeveloperNames

func UpdateDeveloperNames(db *sql.DB, devs map[string]string) error

func UpdateEvents

func UpdateEvents(dbPath, token string) (map[string]int, error)

ImportEvents imports events from GitHub for a given org/repo combination.

Types

type AffiliationImportResult

type AffiliationImportResult struct {
	Duration   string `json:"duration,omitempty"`
	DBDevs     int    `json:"db_devs,omitempty"`
	CNCFDevs   int    `json:"cncf_devs,omitempty"`
	MappedDevs int    `json:"mapped_devs,omitempty"`
}

func UpdateDevelopersWithCNCFEntityAffiliations

func UpdateDevelopersWithCNCFEntityAffiliations(ctx context.Context, db *sql.DB, client *http.Client) (*AffiliationImportResult, error)

UpdateDevelopersWithCNCFEntityAffiliations updates the developers with the CNCF entity affiliations.

type CNCFAffiliation

type CNCFAffiliation struct {
	Entity string `json:"entity,omitempty"`
	From   string `json:"from,omitempty"`
	To     string `json:"to,omitempty"`
}

type CNCFDeveloper

type CNCFDeveloper struct {
	Username     string             `json:"username,omitempty"`
	Identities   []string           `json:"identities,omitempty"`
	Affiliations []*CNCFAffiliation `json:"affiliations,omitempty"`
}

func (*CNCFDeveloper) GetBestIdentity

func (c *CNCFDeveloper) GetBestIdentity() string

func (*CNCFDeveloper) GetLatestAffiliation

func (c *CNCFDeveloper) GetLatestAffiliation() string

type CountedItem

type CountedItem struct {
	Name  string `json:"name,omitempty"`
	Count int    `json:"count,omitempty"`
}

func GetDeveloperPercentages

func GetDeveloperPercentages(db *sql.DB, entity, org, repo *string, ex []string, months int) ([]*CountedItem, error)

GetOrgRepoPercentages returns a list of repo percentages for the given organization.

func GetEntityPercentages

func GetEntityPercentages(db *sql.DB, entity, org, repo *string, ex []string, months int) ([]*CountedItem, error)

GetEntityPercentages returns a list of entity percentages for the given repository.

func QueryEntities

func QueryEntities(db *sql.DB, val string, limit int) ([]*CountedItem, error)

type CountedResult

type CountedResult struct {
	Query   Query            `json:"query,omitempty"`
	Results int              `json:"results,omitempty"`
	Data    map[string]int64 `json:"data,omitempty"`
}

type Developer

type Developer struct {
	Username      string `json:"username,omitempty"`
	FullName      string `json:"full_name,omitempty"`
	Email         string `json:"email,omitempty"`
	AvatarURL     string `json:"avatar,omitempty"`
	ProfileURL    string `json:"url,omitempty"`
	Entity        string `json:"entity,omitempty"`
	Organizations []*Org `json:"organizations,omitempty"`
}

func GetDeveloper

func GetDeveloper(db *sql.DB, username string) (*Developer, error)

func GetGitHubDeveloper

func GetGitHubDeveloper(ctx context.Context, client *http.Client, username string) (*Developer, error)

type DeveloperListItem

type DeveloperListItem struct {
	Username string `json:"username,omitempty"`
	Entity   string `json:"entity,omitempty"`
}

func SearchDevelopers

func SearchDevelopers(db *sql.DB, val string, limit int) ([]*DeveloperListItem, error)

SearchDevelopers returns a list of developers matching the given query.

func SearchGitHubUsers

func SearchGitHubUsers(ctx context.Context, client *http.Client, query string, limit int) ([]*DeveloperListItem, error)

type EntityResult

type EntityResult struct {
	Entity         string               `json:"entity,omitempty"`
	DeveloperCount int                  `json:"developer_count,omitempty"`
	Developers     []*DeveloperListItem `json:"developers,omitempty"`
}

func GetEntity

func GetEntity(db *sql.DB, val string) (*EntityResult, error)

type Event

type Event struct {
	Org      string `json:"org,omitempty"`
	Repo     string `json:"repo,omitempty"`
	Username string `json:"username,omitempty"`
	Type     string `json:"type,omitempty"`
	Date     string `json:"date,omitempty"`
	URL      string `json:"url,omitempty"`
	Mentions string `json:"mentions,omitempty"`
	Labels   string `json:"labels,omitempty"`
}

type EventDetails

type EventDetails struct {
	Event     *Event     `json:"event,omitempty"`
	Developer *Developer `json:"developer,omitempty"`
}

func SearchEvents

func SearchEvents(db *sql.DB, q *EventSearchCriteria) ([]*EventDetails, error)

type EventImporter

type EventImporter struct {
	// contains filtered or unexported fields
}

type EventSearchCriteria

type EventSearchCriteria struct {
	FromDate *string `json:"from,omitempty"`
	ToDate   *string `json:"to,omitempty"`
	Type     *string `json:"type,omitempty"`
	Org      *string `json:"org,omitempty"`
	Repo     *string `json:"repo,omitempty"`
	Username *string `json:"user,omitempty"`
	Entity   *string `json:"entity,omitempty"`
	Mention  *string `json:"mention,omitempty"`
	Label    *string `json:"label,omitempty"`
	Page     int     `json:"page,omitempty"`
	PageSize int     `json:"page_size,omitempty"`
}

func (EventSearchCriteria) String

func (c EventSearchCriteria) String() string

type EventTypeSeries

type EventTypeSeries struct {
	Dates         []string  `json:"dates"`
	PRs           []int     `json:"pr"`
	PRReviews     []int     `json:"pr_review"`
	Issues        []int     `json:"issue"`
	IssueComments []int     `json:"issue_comment"`
	Forks         []int     `json:"fork"`
	Avg           []float32 `json:"avg"`
}

func GetEventTypeSeries

func GetEventTypeSeries(db *sql.DB, org, repo, entity *string, months int) (*EventTypeSeries, error)

type ListItem

type ListItem struct {
	Value string `json:"value,omitempty"`
	Text  string `json:"text,omitempty"`
}

func GetEntityLike

func GetEntityLike(db *sql.DB, query string, limit int) ([]*ListItem, error)

GetEntityLike returns a list of repos that match the given pattern.

func GetOrgLike

func GetOrgLike(db *sql.DB, query string, limit int) ([]*ListItem, error)

GetOrgLike returns a list of orgs and repos that match the given pattern.

func GetRepoLike

func GetRepoLike(db *sql.DB, query string, limit int) ([]*ListItem, error)

GetRepoLike returns a list of repos that match the given pattern.

type Org

type Org struct {
	URL         string `json:"url,omitempty"`
	Name        string `json:"name,omitempty"`
	Company     string `json:"company,omitempty"`
	Description string `json:"description,omitempty"`
}

func GetUserOrgs

func GetUserOrgs(ctx context.Context, client *http.Client, username string, limit int) ([]*Org, error)

type OrgRepoItem

type OrgRepoItem struct {
	Org  string `json:"org,omitempty"`
	Repo string `json:"repo,omitempty"`
}

func GetAllOrgRepos

func GetAllOrgRepos(db *sql.DB) ([]*OrgRepoItem, error)

GetAllOrgRepos returns a list of repo percentages for the given organization.

type Query

type Query struct {
	On    int64  `json:"on,omitempty"`
	Type  string `json:"type,omitempty"`
	Value string `json:"value,omitempty"`
	Limit int    `json:"limit,omitempty"`
}

type Repo

type Repo struct {
	Name        string `json:"name,omitempty"`
	FullName    string `json:"full_name,omitempty"`
	Description string `json:"description,omitempty"`
	URL         string `json:"url,omitempty"`
}

func GetOrgRepos

func GetOrgRepos(ctx context.Context, client *http.Client, org string) ([]*Repo, error)

type State added in v0.3.1

type State struct {
	Since time.Time `json:"since"`
	Page  int       `json:"page"`
}

func GetState

func GetState(db *sql.DB, query, org, repo string, min time.Time) (*State, error)

type Substitution added in v0.3.10

type Substitution struct {
	Prop    string `json:"prop"`
	Old     string `json:"old"`
	New     string `json:"new"`
	Records int64  `json:"records"`
}

func ApplySubstitutions added in v0.3.10

func ApplySubstitutions(db *sql.DB) ([]*Substitution, error)

func SaveAndApplyDeveloperSub added in v0.3.10

func SaveAndApplyDeveloperSub(db *sql.DB, prop, old, new string) (*Substitution, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL