mirror of
https://github.com/lukaszraczylo/git-velocity.git
synced 2026-06-22 04:21:10 +00:00
Fixes calculations (#2)
Git Level (per commit):
- Track unique file paths in FilesModified slice
- FilesChanged = count of unique files in THIS commit
Aggregator Level (per contributor):
- Collect all file paths from all commits into a SET
- FilesChanged = size of the unique file set
Result:
- Contributor.FilesChanged = count of UNIQUE files they touched
- Repository contributor = unique files in THAT repo only
This commit is contained in:
@@ -293,9 +293,11 @@ func (c *Calculator) checkAchievements(cm *models.ContributorMetrics) []string {
|
||||
case "comment_count":
|
||||
earned = float64(cm.ReviewComments) >= ach.Condition.Threshold
|
||||
case "lines_added":
|
||||
earned = float64(cm.LinesAdded) >= ach.Condition.Threshold
|
||||
// Use meaningful lines to match scoring calculation (excludes comments/whitespace)
|
||||
earned = float64(cm.MeaningfulLinesAdded) >= ach.Condition.Threshold
|
||||
case "lines_deleted":
|
||||
earned = float64(cm.LinesDeleted) >= ach.Condition.Threshold
|
||||
// Use meaningful lines to match scoring calculation (excludes comments/whitespace)
|
||||
earned = float64(cm.MeaningfulLinesDeleted) >= ach.Condition.Threshold
|
||||
case "avg_review_time_hours":
|
||||
// For avg review time, lower is better, so lower threshold = harder achievement
|
||||
if cm.AvgReviewTime > 0 && cm.AvgReviewTime <= ach.Condition.Threshold {
|
||||
|
||||
@@ -452,6 +452,8 @@ func TestCalculator_AllAchievementTypes(t *testing.T) {
|
||||
ReviewComments: 25,
|
||||
LinesAdded: 1500,
|
||||
LinesDeleted: 600,
|
||||
MeaningfulLinesAdded: 1500,
|
||||
MeaningfulLinesDeleted: 600,
|
||||
AvgReviewTime: 1.5,
|
||||
UniqueReviewees: 7,
|
||||
RepositoriesContributed: []string{"owner/repo1", "owner/repo2"},
|
||||
|
||||
Reference in New Issue
Block a user