Skip to content

fix(reputation,analytics): compute contributor earnings from payment ledger (#57) - #65

Open
ghzhost wants to merge 1 commit into
MergeFi:mainfrom
ghzhost:fix/contributor-earnings-payment-ledger
Open

fix(reputation,analytics): compute contributor earnings from payment ledger (#57)#65
ghzhost wants to merge 1 commit into
MergeFi:mainfrom
ghzhost:fix/contributor-earnings-payment-ledger

Conversation

@ghzhost

@ghzhost ghzhost commented Aug 16, 2026

Copy link
Copy Markdown

Summary

Fixes #57 by computing a contributor's lifetime and total earnings directly from confirmed records in the Payment ledger, rather than using Bounty.amount (full bounty face value).

Changes

  1. Shared Contributor Earnings Helper (contributor-earnings.util.ts):
    • Implemented computeContributorTotalEarnings(paymentRepo, recipientId) which queries COALESCE(SUM(payment.amount), 0) where payment.recipientId = :recipientId and payment.status = CONFIRMED.
  2. ReputationService (reputation.service.ts):
    • Injected paymentRepo via @InjectRepository(Payment).
    • Updated computeAndSave to use computeContributorTotalEarnings for totalEarnings.
  3. AnalyticsService (analytics.service.ts):
    • Injected paymentRepo via @InjectRepository(Payment).
    • Updated forContributor to use computeContributorTotalEarnings for lifetimeEarnings.
    • Updated topClients computation to sum confirmed payments received by the contributor grouped by escrow.sponsorId.
  4. Modules (reputation.module.ts, analytics.module.ts):
    • Registered Payment entity in TypeOrmModule.forFeature.
  5. Unit Tests:
    • Added unit test suites reputation.service.spec.ts and analytics.service.spec.ts testing team split calculation vs full bounty amount.

Testing

  • npm run build completed successfully with zero TypeScript compilation errors.
  • npm test -- --testPathIgnorePatterns=integration passed (18 test suites, 114 tests).

…ledger (MergeFi#57)

- Query confirmed Payment records by recipientId instead of summing full Bounty.amount
- Extract shared helper computeContributorTotalEarnings for reputation and analytics
- Register Payment entity in ReputationModule and AnalyticsModule
- Calculate topClients in AnalyticsService by summing actual confirmed payments grouped by sponsorId
- Add unit test suites for ReputationService and AnalyticsService verifying team split behavior
@vercel

vercel Bot commented Aug 16, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the chonilius' projects Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant