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:
@@ -1,6 +1,10 @@
|
||||
const { MATCH_STATUS, SUGGESTION_STATUS } = require('./statuses');
|
||||
const { ACCOUNT_TIER, FAIRNESS_SUPPORTER_PENALTY, FAIRNESS_COMFORT_PENALTY } = require('./tiers');
|
||||
|
||||
module.exports = {
|
||||
MATCH_STATUS,
|
||||
SUGGESTION_STATUS,
|
||||
ACCOUNT_TIER,
|
||||
FAIRNESS_SUPPORTER_PENALTY,
|
||||
FAIRNESS_COMFORT_PENALTY,
|
||||
};
|
||||
|
||||
22
backend/src/constants/tiers.js
Normal file
22
backend/src/constants/tiers.js
Normal file
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Account tier constants
|
||||
* Tiers affect recording assignment priority in matchmaking
|
||||
*/
|
||||
const ACCOUNT_TIER = {
|
||||
BASIC: 'BASIC', // Default tier - normal recording assignment frequency
|
||||
SUPPORTER: 'SUPPORTER', // Moderately reduced recording assignment frequency
|
||||
COMFORT: 'COMFORT', // Significantly reduced recording assignment frequency
|
||||
};
|
||||
|
||||
/**
|
||||
* Fairness penalties for different tiers
|
||||
* Higher penalty = less likely to be assigned as recorder
|
||||
*/
|
||||
const FAIRNESS_SUPPORTER_PENALTY = 10; // Supporter slightly less likely to record
|
||||
const FAIRNESS_COMFORT_PENALTY = 50; // Comfort significantly less likely to record
|
||||
|
||||
module.exports = {
|
||||
ACCOUNT_TIER,
|
||||
FAIRNESS_SUPPORTER_PENALTY,
|
||||
FAIRNESS_COMFORT_PENALTY,
|
||||
};
|
||||
Reference in New Issue
Block a user