import { Controller, Get, Param, Query } from '@nestjs/common';
import { SessionsService, SessionsResult, SessionMetrics, SessionRecord } from './sessions.service';
import { SessionsQueryDto, SessionMetricsQueryDto } from './dto/sessions-query.dto';

@Controller('sessions')
export class SessionsController {
  constructor(private readonly sessionsService: SessionsService) {}

  /**
   * Get list of sessions with filtering and pagination
   * GET /sessions?startDate=2024-01-01&endDate=2024-01-31&limit=50&offset=0
   */
  @Get()
  async getSessions(@Query() query: SessionsQueryDto): Promise<SessionsResult> {
    return this.sessionsService.getSessions(query);
  }

  /**
   * Get aggregated session metrics
   * GET /sessions/metrics?startDate=2024-01-01&endDate=2024-01-31
   */
  @Get('metrics')
  async getSessionMetrics(@Query() query: SessionMetricsQueryDto): Promise<SessionMetrics> {
    return this.sessionsService.getSessionMetrics(query);
  }

  /**
   * Get single session by ID
   * GET /sessions/:sessionId
   */
  @Get(':sessionId')
  async getSession(@Param('sessionId') sessionId: string): Promise<SessionRecord | null> {
    return this.sessionsService.getSession(sessionId);
  }
}
