Skip to content

Commit

Permalink
add organization whitelist configuration for code contribution
Browse files Browse the repository at this point in the history
  • Loading branch information
chengjoey committed Apr 23, 2024
1 parent a06b0fc commit e02e7fe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions internal/tools/gittar/conf/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ type Conf struct {

// metrics
RefreshPersonalContributorDuration time.Duration `default:"12h" env:"REFRESH_PERSONAL_CONTRIBUTOR_DURATION"`
PersonalContributionOrgIDWhiteList []uint64 `env:"PERSONAL_CONTRIBUTION_ORG_ID_WHITE_LIST"`
MetricTargetBranches []string `env:"METRIC_TARGET_BRANCHES" default:"[\"master\",\"main\",\"dev\",\"develop\",\"release\",\"feature/develop\"]"`

// AI
Expand Down Expand Up @@ -216,6 +217,10 @@ func RefreshPersonalContributorDuration() time.Duration {
return cfg.RefreshPersonalContributorDuration
}

func PersonalContributionOrgIDWhiteList() []uint64 {
return cfg.PersonalContributionOrgIDWhiteList
}

func MetricTargetBranches() []string {
return cfg.MetricTargetBranches
}
Expand Down
8 changes: 6 additions & 2 deletions internal/tools/gittar/metrics/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,14 @@ func (c *Collector) RefreshPersonalContributions() error {
now := time.Now()
start := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local)
end := time.Date(now.Year(), now.Month(), now.Day(), 23, 59, 59, 0, time.Local)
contributions, err := c.IterateRepos(apistructs.GittarListRepoRequest{
req := apistructs.GittarListRepoRequest{
Start: &start,
End: &end,
})
}
if len(conf.PersonalContributionOrgIDWhiteList()) > 0 {
req.OrgIDs = conf.PersonalContributionOrgIDWhiteList()
}
contributions, err := c.IterateRepos(req)
if err != nil {
return err
}
Expand Down

0 comments on commit e02e7fe

Please sign in to comment.