model

package
v0.0.0-...-2f0a4f1 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2023 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingRepoPathParameter  = errors.New("missing repo path parameter")
	ErrMissingOwnerPathParameter = errors.New("missing owner path parameter")
	ErrAppNotInstalled           = errors.New("GitHub app not installed for given repository")

	ErrIssueMissingAssignee    = errors.New("the issue is missing an assignee")
	ErrIssueMissingClosedAt    = errors.New("the issue is missing the closed at timestamp")
	ErrIssueMissingPullRequest = errors.New("the issue is missing a pull request")

	ErrEventMissingData            = errors.New("the event is missing data promised by the GitHub API")
	ErrEventNotRepoAdded           = errors.New("the event is not a repo added to github event")
	ErrEventNotInstallationCreated = errors.New("the event is not a github created event")

	ErrEventNotHandled = errors.New("the event is not handled")
)
View Source
var ErrNoWorkLogForAssignee = errors.New("no work log found for assignee")

Functions

func NewInstallationIssue

func NewInstallationIssue(configPullRequest *model.PullRequest, hasTrackedIssue bool, badgeURL BadgeURLs, state model.IssueState, labels []string) (model.IssueRequest, error)

NewInstallationIssue creates a new InstallationIssue from a given title, a config pull request and a boolean indicating whether an issue is tracked by the famed protocol.

Types

type BadgeStyle

type BadgeStyle string
const (
	BadgeStyleSmall      BadgeStyle = "small"
	BadgeStyleLargeLight BadgeStyle = "large-light"
	BadgeStyleLargeDark  BadgeStyle = "large-dark"
)

func NewBadgeStyleFromQuery

func NewBadgeStyleFromQuery(query string) BadgeStyle

type BadgeURLs

type BadgeURLs struct {
	BadgeSmall      string
	BadgeLargeLight string
	BadgeLargeDark  string
}

func NewBadgeURLs

func NewBadgeURLs(baseURL, owner, repoName string) BadgeURLs

type BoardOptions

type BoardOptions struct {
	Currency        string
	RewardStructure RewardStructure
	Now             time.Time
}

func NewBoardOptions

func NewBoardOptions(currency string, rewardStructure RewardStructure, now time.Time) BoardOptions

type Config

type Config struct {
	Currency                 string
	Rewards                  map[model.IssueSeverity]float64
	Labels                   map[string]model.Label
	DaysToFix                int
	BotLogin                 string
	InstallationPRBranchName string
	ScannerWorkflowPath      string
	PRAuthorEmail            string
}

func NewFamedConfig

func NewFamedConfig(currency string, rewards map[model.IssueSeverity]float64, labels map[string]model.Label, daysToFix int, botLogin, installationPRBranchName, scannerWorkflowPath, prAuthorEmail string) Config

NewFamedConfig returns a new instance of the famed config.

type Contributor

type Contributor struct {
	Login            string                      `json:"login"`
	AvatarURL        string                      `json:"avatarUrl"`
	HTMLURL          string                      `json:"htmlUrl"`
	FixCount         int                         `json:"fixCount"`
	Rewards          []RewardEvent               `json:"rewards"`
	RewardSum        float64                     `json:"rewardSum"`
	Currency         string                      `json:"currency"`
	RewardsLastYear  RewardsLastYear             `json:"rewardsLastYear"`
	TimeToDisclosure TimeToDisclosure            `json:"timeToDisclosure"`
	Severities       map[model.IssueSeverity]int `json:"severities"`
	MeanSeverity     float64                     `json:"meanSeverity"`
	// For issue rewardComment generation
	TotalWorkTime time.Duration `json:"-"`
}

func NewBlueTeamFromIssue

func NewBlueTeamFromIssue(issue model.EnrichedIssue, options BoardOptions) ([]*Contributor, error)

NewBlueTeamFromIssue returns a contributors map generated from the repo's internal issue with issueID and its corresponding events.

func NewBlueTeamFromIssues

func NewBlueTeamFromIssues(issues map[int]model.EnrichedIssue, options BoardOptions) []*Contributor

NewBlueTeamFromIssues generates a blue team from a given slice of enriched issues.

func NewRedTeamFromIssues

func NewRedTeamFromIssues(issues []model.Issue, currency string, now time.Time) ([]*Contributor, error)

NewRedTeamFromIssues returns contributors of the red team for a given set of issues.

type Contributors

type Contributors map[string]*Contributor

func (Contributors) UpdateRewards

func (cs Contributors) UpdateRewards(url string, workLogs WorkLogs, open, close time.Time, k int, severity model.IssueSeverity, boardOptions BoardOptions)

UpdateRewards updates the reward for each contributor based on open (time when issue was opened) close (time issue was closed) k (number of times the issue was reopened) workLogs (time each contributor worked on the issue).

type RewardEvent

type RewardEvent struct {
	Date   time.Time `json:"date"`
	Reward float64   `json:"reward"`
	URL    string    `json:"url"`
}

type RewardStructure

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

func NewRewardStructure

func NewRewardStructure(severityReward map[model.IssueSeverity]float64, maxDaysToFix, kMultiplier int) RewardStructure

func (RewardStructure) Reward

func (RW RewardStructure) Reward(t time.Duration, k int, severity model.IssueSeverity) float64

Reward returns the base reward multiplied by the severity reward.

type RewardsLastYear

type RewardsLastYear []monthlyReward

func NewRewardsLastYear

func NewRewardsLastYear(timeStart time.Time) RewardsLastYear

NewRewardsLastYear returns rewardsLastYear with instantiated months starting at the current month and going back 11 months.

type TimeToDisclosure

type TimeToDisclosure struct {
	Time              []float64 `json:"time"`
	Mean              float64   `json:"mean"`
	StandardDeviation float64   `json:"standardDeviation"`
}

type WorkLog

type WorkLog struct {
	Start time.Time
	End   time.Time
}

type WorkLogs

type WorkLogs map[string][]WorkLog

func (WorkLogs) Add

func (wL WorkLogs) Add(login string, workLog WorkLog)

Add adds a new WorkLog.

func (WorkLogs) Sum

func (wL WorkLogs) Sum() (map[string]time.Duration, time.Duration)

Sum returns the sum of work per contributor and the total sum of work.

func (WorkLogs) UpdateEnd

func (wL WorkLogs) UpdateEnd(login string, end time.Time) error

UpdateEnd updates the end time of the last work log of an assignee.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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