Feature/requests bounty#9
Merged
Merged
Conversation
Requests & Bounty: - Prisma schema: Request, RequestBounty, RequestArtist, RequestAction, RequestFill models; RequestStatus and RequestActionType enums - EconomyTransaction model with typed EconomyTransactionReason enum and actorUserId for audit attribution - requests module: createRequest, addBounty, fillRequest (atomic CAS), unfillRequest, deleteRequest (staff/owner), listRequests, serializeRequest - GET/POST /api/requests, /api/requests/:id, /api/requests/:id/bounty, /api/requests/:id/fill, /api/requests/:id/unfill, DELETE /api/requests/:id - Zod schemas for all request endpoints with proper query/param validation - Service-level and route-level test suites (80 tests) Download economy (Phase 1): - DownloadGrantStatus enum; DOWNLOAD_DEBIT, DOWNLOAD_CREDIT, STAFF_REVERSAL added to EconomyTransactionReason - DownloadAccessGrant model: atomic grant creation, idempotency window, immutable dual-ledger entries, Consumer relation upsert - Contribution.approvedAccountingBytes (BigInt) for files > 2 GiB - downloadUrl stripped from all contribution API responses; gated behind POST /api/contributions/:id/access - downloads module: grantDownloadAccess (CAS balance check, 120s idempotency), reverseDownloadAccess (staff clawback with full ledger reversal) - GET /api/contributions/:id/access/latest, POST /api/downloads/:grantId/reverse - Service-level and route-level tests for all download paths (23 tests) - Updated apiTestHarness with downloadAccessGrant and contribution mocks Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds User.totalEarned (BigInt, default 0) as a gross earnings counter that only moves upward during normal operation. Unlike User.uploaded (net spendable balance), totalEarned is never decremented by spending — only by staff reversals — making it a clean ratio numerator for Phase 3. - Schema: totalEarned BigInt @default(0) on User - Migration: ADD COLUMN + backfill from existing DOWNLOAD_CREDIT ledger rows - grantDownloadAccess: increments contributor totalEarned alongside uploaded - reverseDownloadAccess: decrements contributor totalEarned alongside uploaded - Tests updated to assert totalEarned is touched in both paths Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Ratio module (src/modules/ratio.ts): - computeRatio(totalEarned, downloaded): returns 1.0 when downloaded is 0 - getDownloadBracket: 10-step bracket table (0–5 GiB through 100+ GiB) - computeRequiredRatio: max(minRequired, maxRequired * (1 - coverage)) where coverage = min(1, eligibleBytes / downloaded) - getEligibleContributionBytes: sums approvedAccountingBytes (falling back to sizeInBytes) for contributions older than 72 hours - getRatioStats: full stats DTO for API response Downloads module: - grantDownloadAccess: updates User.ratio atomically in the CAS updateMany using the consumer's current totalEarned and post-debit downloaded value - reverseDownloadAccess: recalculates and updates ratio for both consumer and contributor after clawback Profile route: - GET /profile/user/:userId now includes uploaded, downloaded, totalEarned, ratio in the response - New GET /profile/me/ratio endpoint returning full RatioStats 18 new ratio tests; 121 total passing Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds RatioPolicyState model tracking OK → WATCH → LEECH_DISABLED transitions. evaluateRatioPolicy runs fire-and-forget after each download grant; staff can view and override state via new routes. Profile /me/ratio endpoint now includes policy state. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds LinkHealthStatus enum and linkStatus/linkCheckedAt columns. HEAD-checks contribution URLs async on submission and daily via background job. Users can report dead links; 3 reports auto-sets WARN and triggers a recheck. Staff can set approvedAccountingBytes via PUT /contributions/:id/approve. Ratio coverage now only counts staff-approved contributions. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
A single user filing 3 reports should not trigger auto-WARN. Uses Prisma distinct query to count unique reporterIds. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 250 |
| Duplication | 33 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
- Replace `any` casts with typed intermediates in mock call assertions - Use ReleaseType/RequestStatus enum imports instead of string casts - Fix BigInt.prototype augmentation to use double-cast (no bare `any`) - Remove unused imports (asyncHandler, getPolicyState, addBounty) - Fix OPEN_REQUEST.createdAt to use Date instead of ISO string - Prettier formatting on all modified files Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
No description provided.