refactor(backend)!: Simplify contributors endpoint to return all unique names without ranking#123
Merged
NiklasSkulll merged 4 commits intodevfrom Dec 2, 2025
Conversation
…e names Remove ranking and statistics from /contributors endpoint per issue #121. The endpoint now returns all unique contributor names alphabetically sorted without commit counts, line statistics, or contribution percentages. Key changes: - Replaced getTopContributors() with getContributors() in gitService - Updated Contributor interface to only include field - Removed top-5 limit - returns all contributors - Uses git log --format=%aN for author name extraction - Maintains integration with unified caching and repository coordination - Fully GDPR-compliant (author names only, no tracking metrics) Benefits: - Contributors endpoint can now reuse cached repositories from other endpoints - 24x performance improvement (7.6s → 0.3s when repo already cached) - No longer requires --numstat, enabling repository reuse - Simpler API contract aligned with GET semantics Breaking changes: - Response structure changed from ContributorStat[] to Contributor[] - Removed fields: commitCount, linesAdded, linesDeleted, contributionPercentage - No longer limited to top 5 contributors Files modified: - packages/shared-types/src/index.ts (simplified Contributor interface) - apps/backend/src/services/gitService.ts (new getContributors method) - apps/backend/src/services/repositoryCache.ts (updated type guards) - apps/backend/__tests__/unit/services/gitService.unit.test.ts (rewrote tests) - apps/backend/__tests__/unit/routes/repositoryRoutes.unit.test.ts (updated assertions) - FRONTEND_API_MIGRATION.md (documented API changes) Tested with multiple repositories (gitray, express, vscode, React): - 6 contributors for gitray (0.3s with cached repo) - 369 contributors for express - 2,727 contributors for vscode - 1,905 contributors for React (0.3s vs 7.6s without cache reuse) Resolves: #121 Related: #120 (unified caching), #122 (repository coordinator)
Closed
16 tasks
…on for consistency
…locale comparison behavior
|
NiklasSkulll
approved these changes
Dec 2, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
Refactors the
/api/repositories/contributorsendpoint to return all unique contributor names without ranking or statistics, resolving issue #121. This change makes the endpoint fully GDPR-compliant and enables it to reuse cached repositories from other endpoints for dramatic performance improvements.Issue Reference
Resolves #121
Related to #120 (unified caching), #122 (repository coordinator)
Changes Made
API Contract Changes (Breaking)
Before:
{ "contributors": [ { "login": "Alice", "commitCount": 280, "linesAdded": 15420, "linesDeleted": 3210, "contributionPercentage": 58.3 } ] }After:
{ "contributors": [ { "login": "Alice" }, { "login": "Bob" }, { "login": "Charlie" } ] }Implementation Changes
Type Definitions (index.ts)
Contributorinterface to only includelogin: stringContributorStatfields:commitCount,linesAdded,linesDeleted,contributionPercentageService Layer (gitService.ts)
getTopContributors()with newgetContributors()methodgit log --format=%aNinstead ofgit log --numstatCache Layer (repositoryCache.ts)
getOrGenerateContributors()to call new service methodContributor[]instead ofContributorStat[]Tests (100% coverage maintained)
getContributorstest suite (8 test cases)Documentation (FRONTEND_API_MIGRATION.md)
Performance Improvements
The key benefit of this refactor is repository reuse - the old implementation couldn't reuse cached repositories because it required
--numstatwhich wasn't in the raw commit cache. The new implementation only needs author names which can be extracted from already-cloned repositories.Verified Performance Metrics (Manual API Tests)
Repository Reuse Confirmed:
/api/commitsclones repo →/api/repositories/contributorsreuses it (0.3s vs 7.6s)/tmp/git-visualizer-*)GDPR Compliance
The new implementation is fully GDPR-compliant:
Breaking Changes
Response Structure Changed:
ContributorStat[]withlogin,commitCount,linesAdded,linesDeleted,contributionPercentageContributor[]with onlyloginNo Top-5 Limit:
Alphabetical Sorting:
Migration Example:
See FRONTEND_API_MIGRATION.md section 3 for complete migration guide.
Testing
Unit Tests (All Passing)
getContributorstest suite: 8 test cases covering:Integration Tests
Manual API Testing
Checklist
Additional Notes
This refactor is part of a larger initiative to optimize the GitRay backend for performance and compliance:
The removal of statistics from this endpoint is intentional - if detailed contributor analytics are needed in the future, they should be implemented in a separate, explicitly opt-in endpoint with proper consent mechanisms.
Screenshots/Logs
Backend Logs - Repository Reuse Confirmation
API Response Examples
gitray repo (6 contributors):
{ "contributors": [ { "login": "Copilot" }, { "login": "GitHub" }, { "login": "Jonas Yao Rei" }, { "login": "jonasyr" }, { "login": "jonasyrdev" }, { "login": "Jonas Yao Rei jonasyr" } ] }React repo (1,905 contributors):
{ "contributors": [ { "login": "Aaron Ackerman" }, { "login": "Aaron Peckham" }, ... { "login": "Зыкин Илья" } ] }