Fix tests.

This commit is contained in:
2025-12-10 21:38:05 +00:00
parent 9b7e07b3c6
commit f0a72ae4fc
3 changed files with 11 additions and 3 deletions
+7
View File
@@ -383,6 +383,13 @@ func (a *Aggregator) Aggregate(data *models.RawData, dateRange *config.ParsedDat
if !contains(cm.RepositoriesContributed, issue.Repository) {
cm.RepositoriesContributed = append(cm.RepositoriesContributed, issue.Repository)
}
// Update per-repo contributor metrics
rcm := getRepoContributor(issue.Repository, login, cm.Name, cm.AvatarURL)
rcm.IssuesOpened++
if issue.IsClosed() && issue.ClosedBy != nil && issue.ClosedBy.Login == login {
rcm.IssuesClosed++
}
}
// Calculate averages and finalize contributor metrics
+3 -2
View File
@@ -646,9 +646,10 @@ func TestCalculator_MultipleRepositories(t *testing.T) {
// 50 + 30 = 80 commits * 10 = 800
assert.Equal(t, 800, result.Leaderboard[0].Score)
// Both repos should be tracked
// Per-repo scores should reflect repo-specific metrics, not global
// Repo1 has 50 commits * 10 = 500
contributor := result.Repositories[0].Contributors[0]
assert.Equal(t, 800, contributor.Score.Total)
assert.Equal(t, 500, contributor.Score.Total)
}
func TestCalculator_EmptyMetrics(t *testing.T) {
+1 -1
View File
@@ -100,7 +100,7 @@ func TestGenerator_GenerateGlobalJSON(t *testing.T) {
TotalReviews int `json:"total_reviews"`
TotalLinesAdded int `json:"total_lines_added"`
TotalLinesDeleted int `json:"total_lines_deleted"`
GeneratedAt time.Time `json:"GeneratedAt"`
GeneratedAt time.Time `json:"generated_at"`
}
err = json.Unmarshal(data, &result)
require.NoError(t, err)