import { Controller, Get, Param, Post, Query } from '@nestjs/common';
import { RunsService } from './runs.service';

@Controller('/api/runs')
export class RunsController {
  constructor(private readonly runsService: RunsService) {}

  @Get('/report')
  getInspectionReport(@Query('date') date?: string) {
    return this.runsService.getInspectionReport(date);
  }

  @Get()
  getRuns(
    @Query('taskId') taskId?: string,
    @Query('status')
    status?: 'queued' | 'running' | 'success' | 'failed' | 'partial',
  ) {
    return this.runsService.getRuns({ taskId, status });
  }

  @Get('/:runId')
  getRunDetail(@Param('runId') runId: string) {
    return this.runsService.getRunDetail(runId);
  }

  @Post('/execute/:taskId')
  executeTask(@Param('taskId') taskId: string) {
    return this.runsService.executeTask(taskId);
  }
}
