feat(matching): implement 3-tier account system with fairness-based recording assignment
Add account tier system (BASIC/SUPPORTER/COMFORT) to reduce recording burden for premium users while maintaining fairness through karma-based assignment. Database Changes: - Add AccountTier enum (BASIC, SUPPORTER, COMFORT) - Add User.accountTier with BASIC default - Add User.recordingsDone and User.recordingsReceived for karma tracking - Add EventParticipant.accountTierOverride for event-specific tier upgrades - Migration: 20251129220604_add_account_tiers_and_recording_stats Matching Algorithm Updates: - Implement fairness debt calculation: receivedCount - doneCount - Apply tier penalties: SUPPORTER (-10), COMFORT (-50) - New sorting priority: Location > Fairness > Load balancing - Add getEffectiveTier() helper for tier resolution with override support - Add getRecordingStatsForUsers() for fetching karma statistics Tier Behavior: - BASIC: Normal recording frequency (baseline, no penalty) - SUPPORTER: Moderately reduced frequency (fairness penalty -10) - COMFORT: Significantly reduced frequency (fairness penalty -50) - All tiers can still be assigned when no better candidates available Constants: - ACCOUNT_TIER enum in src/constants/tiers.js - FAIRNESS_SUPPORTER_PENALTY = 10 - FAIRNESS_COMFORT_PENALTY = 50 Tests: - Update tests for dual buffer system semantics - All 30 tests passing - Fix imports: HEAT_BUFFER → HEAT_BUFFER_BEFORE
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "AccountTier" AS ENUM ('BASIC', 'SUPPORTER', 'COMFORT');
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "event_participants" ADD COLUMN "account_tier_override" "AccountTier";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "account_tier" "AccountTier" NOT NULL DEFAULT 'BASIC',
|
||||
ADD COLUMN "recordings_done" INTEGER NOT NULL DEFAULT 0,
|
||||
ADD COLUMN "recordings_received" INTEGER NOT NULL DEFAULT 0;
|
||||
Reference in New Issue
Block a user