import { Body, Controller, Get, Post } from '@nestjs/common';
import { RedmineEventsGateway } from '../events/redmine-events.gateway';

export type PingResponse = { success: boolean };

@Controller('redmine-event-emitter')
export class MainController {
  constructor(private readonly redmineEventsGateway: RedmineEventsGateway) {}

  @Get('ping')
  ping(): PingResponse {
    return { success: true };
  }

  @Post('append-issues')
  async appendIssues(@Body() issues: number[]): Promise<void> {
    this.redmineEventsGateway.addIssues(issues);
  }

  @Get('get-issues-queue-size')
  getIssuesQueueSize(): number {
    return this.redmineEventsGateway.getQueueSize();
  }

  @Get('get-issues-queue')
  getIssuesQueue(): number[] {
    return this.redmineEventsGateway.getQueueIssues();
  }
}
