Skip to content

Commit

Permalink
remove commits stats data directly from PRs, add consumed time of pro…
Browse files Browse the repository at this point in the history
…gram, sort by PRs by default
  • Loading branch information
bruceauyeung committed Feb 17, 2017
1 parent 62d9735 commit fc27b4c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
9 changes: 4 additions & 5 deletions config.toml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ dimension = "all"
# Sunday:0; Monday:1; Tuesday:2; Wednesday:3; Thursday:4; Friday:5; Saturday:6
weekFirstDay=6

[[users]]
name = "bruceauyeung" # github user names who contribute to the specified repositories.
stackalyticsDeviation = 1
# no sort:0; sort by merged PRs:1;sort by merged commits:2;
sort=1

[[users]]
name = "tanshanshan"
stackalyticsDeviation = 0
name = "bruceauyeung"
realName = "欧阳钦华"
6 changes: 6 additions & 0 deletions githubstat/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import (
const (
DimensionOverall = "Overall"
DimensionWeek = "Week"

NoSort = 0
SortByMergedPRs = 1
SortByMergedCommits = 2
)

type Load interface {
Expand All @@ -20,6 +24,7 @@ type User struct {
Name string
RealName string
}

type Configuration struct {
StatBeginTime time.Time
StatEndTime time.Time
Expand All @@ -30,6 +35,7 @@ type Configuration struct {
Dimension string
WeekFirstDay time.Weekday
ThisWeekFirstDay time.Time
Sort int
}

func getWeekFirstDay(t time.Time) time.Time {
Expand Down
15 changes: 13 additions & 2 deletions githubstat/metrics_pull_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,19 @@ func getRealName(userName string) string {
return ""
}
func sortMetrics(toBeSort []*PullRequestMetrics) []*PullRequestMetrics {
sort.Slice(toBeSort, func(i, j int) bool { return toBeSort[i].MergedCommits > toBeSort[j].MergedCommits })
return toBeSort
switch Config.Sort {
case NoSort:
return toBeSort
case SortByMergedPRs:
sort.Slice(toBeSort, func(i, j int) bool { return toBeSort[i].Merged > toBeSort[j].Merged })
return toBeSort
case SortByMergedCommits:
sort.Slice(toBeSort, func(i, j int) bool { return toBeSort[i].MergedCommits > toBeSort[j].MergedCommits })
return toBeSort
default:
return toBeSort

}
}
func merge(toBeMerged []*PullRequestMetrics) []*PullRequestMetrics {
// user name to slice index of the first occurence of user's metrics
Expand Down

0 comments on commit fc27b4c

Please sign in to comment.