estimate

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EstimateTimeToReviewCmd = &cobra.Command{
	Use:   "estimate-review",
	Short: "Estimate time needed to review a PR in seconds",
	PreRunE: func(cmd *cobra.Command, args []string) error {
		if addLabel && ghToken == "" {
			return fmt.Errorf("github token needs to be specified to add a label")
		}
		viper.AddConfigPath(defaultConfigPath)
		if err := viper.ReadInConfig(); err != nil {
			return fmt.Errorf("error reading in config: %+v", err)
		}
		if err := viper.Unmarshal(&config); err != nil {
			return fmt.Errorf("failed to parse config: %+v", err)
		}
		return nil
	},
	RunE: func(cmd *cobra.Command, args []string) error {
		client := github.NewClient(nil)
		if ghToken != "" {
			client.WithAuthToken(ghToken)
		}

		review, err := TimeToReview(client, owner, repository, prNumber)
		if err != nil {
			return err
		}

		if human {
			fmt.Printf("Estimated time to review %s/%s#%d is %d seconds (~%d minutes)\n", owner, repository, prNumber, review, review/60)
		} else {
			fmt.Println(review)
		}
		if addLabel {
			err := addLabelToPR(client, review)
			if err != nil {
				return err
			}
		}
		return nil
	},
}

EstimateTimeToReviewCmd is a cobra command that estimates time needed to review a PR

Functions

func TimeToReview

func TimeToReview(client *github.Client, owner, repository string, number int) (int, error)

TimeToReview estimates time needed to review a PR

Types

type CoefficientConfig

type CoefficientConfig struct {
	Weight  float64 `yaml:"weight"`
	Ceiling float64 `yaml:"ceiling"`
}

CoefficientConfig represents coefficients used in estimation of time required for a PR review

type TimeLabel

type TimeLabel struct {
	Name string `yaml:"name"`
	Time int    `yaml:"time"`
}

TimeLabel represents a label describing estimated time to review a PR

Jump to

Keyboard shortcuts

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