api client refactor
This commit is contained in:
30
apps/website/lib/view-models/AnalyticsDashboardViewModel.ts
Normal file
30
apps/website/lib/view-models/AnalyticsDashboardViewModel.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
// Analytics dashboard view model
|
||||
// Represents dashboard data for analytics
|
||||
|
||||
export class AnalyticsDashboardViewModel {
|
||||
totalUsers: number;
|
||||
activeUsers: number;
|
||||
totalRaces: number;
|
||||
totalLeagues: number;
|
||||
|
||||
constructor(data: { totalUsers: number; activeUsers: number; totalRaces: number; totalLeagues: number }) {
|
||||
Object.assign(this, data);
|
||||
}
|
||||
|
||||
/** 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';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user