import { Controller, Get, Post, Query, Body, UseGuards } from '@nestjs/common';
import { DashboardService } from './dashboard.service';
import { AdminGuard } from '../../../common/guards/admin.guard';

@Controller('api/v1/admin/dashboard')
@UseGuards(AdminGuard)
export class DashboardController {
  constructor(private readonly dashboardService: DashboardService) {}

  @Get('stats')
  async getStats() {
    return this.dashboardService.getStats();
  }

  @Get('activity-distribution')
  async getActivityDistribution() {
    return this.dashboardService.getActivityDistribution();
  }

  @Get('analytics/user-growth')
  async getUserGrowth(@Query('days') days?: string) {
    const daysNum = days ? parseInt(days, 10) : 7;
    return this.dashboardService.getUserGrowth(daysNum);
  }

  @Get('analytics/device-distribution')
  async getDeviceDistribution() {
    return this.dashboardService.getDeviceDistribution();
  }

  @Get('analytics/activity-by-day')
  async getActivityByDay(@Query('days') days?: string) {
    const daysNum = days ? parseInt(days, 10) : 7;
    return this.dashboardService.getActivityByDay(daysNum);
  }

  @Get('analytics/age-distribution')
  async getAgeDistribution() {
    return this.dashboardService.getAgeDistribution();
  }

  @Get('analytics/engagement-pattern')
  async getEngagementPattern(@Query('days') days?: string) {
    const daysNum = days ? parseInt(days, 10) : 7;
    return this.dashboardService.getEngagementPattern(daysNum);
  }

  @Get('health')
  async getSystemHealth() {
    return this.dashboardService.getSystemHealth();
  }

  @Get('settings')
  async getSettings() {
    return this.dashboardService.getSettings();
  }

  @Post('settings')
  async updateSettings(@Body() settings: any) {
    return this.dashboardService.updateSettings(settings);
  }
}
