import { Controller, Get } from "@nestjs/common";
import { WhmcsRequestQueueService } from "@bff/core/queue/services/whmcs-request-queue.service";
import { SalesforceRequestQueueService } from "@bff/core/queue/services/salesforce-request-queue.service";

@Controller("health/queues")
export class QueueHealthController {
  constructor(
    private readonly whmcsQueue: WhmcsRequestQueueService,
    private readonly salesforceQueue: SalesforceRequestQueueService
  ) {}

  @Get()
  getQueueHealth() {
    return {
      timestamp: new Date().toISOString(),
      whmcs: {
        health: this.whmcsQueue.getHealthStatus(),
        metrics: this.whmcsQueue.getMetrics(),
      },
      salesforce: {
        health: this.salesforceQueue.getHealthStatus(),
        metrics: this.salesforceQueue.getMetrics(),
        dailyUsage: this.salesforceQueue.getDailyUsage(),
      },
    };
  }

  @Get("whmcs")
  getWhmcsQueueMetrics() {
    return {
      timestamp: new Date().toISOString(),
      health: this.whmcsQueue.getHealthStatus(),
      metrics: this.whmcsQueue.getMetrics(),
    };
  }

  @Get("salesforce")
  getSalesforceQueueMetrics() {
    return {
      timestamp: new Date().toISOString(),
      health: this.salesforceQueue.getHealthStatus(),
      metrics: this.salesforceQueue.getMetrics(),
      dailyUsage: this.salesforceQueue.getDailyUsage(),
    };
  }
}
