/** * Analytics dashboard view model * * View model for analytics dashboard data. * * Accepts AnalyticsDashboardInputViewData as input and produces UI-ready data. */ import { AnalyticsDashboardInputViewData } from "../view-data/AnalyticsDashboardInputViewData"; import { ViewModel } from "../contracts/view-models/ViewModel"; export class AnalyticsDashboardViewModel extends ViewModel { readonly totalUsers: number; readonly activeUsers: number; readonly totalRaces: number; readonly totalLeagues: number; constructor(viewData: AnalyticsDashboardInputViewData) { super(); this.totalUsers = viewData.totalUsers; this.activeUsers = viewData.activeUsers; this.totalRaces = viewData.totalRaces; this.totalLeagues = viewData.totalLeagues; } /** UI-specific: User engagement rate */ get userEngagementRate(): number { return this.totalUsers > 0 ? (this.activeUsers / this.totalUsers) * 100 : 0; } /** UI-specific: Formatted engagement rate */ get formattedEngagementRate(): string { return `${this.userEngagementRate.toFixed(1)}%`; } /** UI-specific: Activity level */ get activityLevel(): string { if (this.userEngagementRate > 70) return 'High'; if (this.userEngagementRate > 40) return 'Medium'; return 'Low'; } }