refactor(backend)!: Simplify contributors endpoint to return all unique names without ranking #123
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": "Зыкин Илья" } ] }