Description
When a builder receives testimonials, project awards, or positive peer reviews, reputation points are awarded to their account via backend/app/routers/user_reputation.py. If a spammy or fraudulent review is subsequently deleted by moderators or retracted by the author, the previously credited reputation points are never deducted, corrupting leaderboard integrity (frontend/src/routes/_app.leaderboard.tsx).
Steps to Reproduce
- User A writes a testimonial for User B (User B receives +50 reputation points).
- User A deletes the testimonial or an Admin soft-deletes it for policy violations.
- User B retains the +50 points permanently on the global leaderboard.
Expected Behavior
- Backend: Implement an event-driven reputation audit ledger (
ReputationLedger model). On soft-delete or retraction of source events, automatically create an offsetting negative ledger entry and recompute aggregate reputation.
- Frontend: Display an audit trail of points earned/deducted in the user's reputation dashboard.
Implementation Hints
Backend (backend/app/routers/user_reputation.py):
async def rollback_reputation_points(
db: AsyncSession,
user_id: UUID,
source_type: str,
source_id: UUID
):
original_tx = await db.scalar(
select(ReputationLedger).where(
ReputationLedger.user_id == user_id,
ReputationLedger.source_type == source_type,
ReputationLedger.source_id == source_id,
ReputationLedger.is_reverted.is_(False)
)
)
if original_tx:
original_tx.is_reverted = True
offsetting_tx = ReputationLedger(
user_id=user_id,
points=-original_tx.points,
reason=f"Rollback: {source_type} deleted",
source_type=source_type,
source_id=source_id
)
db.add(offsetting_tx)
await db.commit()
Affected Files
- backend/app/routers/user_reputation.py
- backend/app/models/user.py
- frontend/src/routes/_app.leaderboard.tsx
Labels
type:feature, level:advanced, GSSoC-26
Description
When a builder receives testimonials, project awards, or positive peer reviews, reputation points are awarded to their account via
backend/app/routers/user_reputation.py. If a spammy or fraudulent review is subsequently deleted by moderators or retracted by the author, the previously credited reputation points are never deducted, corrupting leaderboard integrity (frontend/src/routes/_app.leaderboard.tsx).Steps to Reproduce
Expected Behavior
ReputationLedgermodel). On soft-delete or retraction of source events, automatically create an offsetting negative ledger entry and recompute aggregate reputation.Implementation Hints
Backend (
backend/app/routers/user_reputation.py):Affected Files
Labels
type:feature, level:advanced, GSSoC-26