"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getApplicationsCount = void 0;
const drizzle_orm_1 = require("drizzle-orm");
const database_1 = require("../../../database");
const tables_1 = require("../../../database/tables");
const logger_1 = __importDefault(require("../../../logger"));
const getApplicationsCount = async (req, res) => {
    try {
        const db = await (0, database_1.getDb)();
        // Get total count of applications (excluding archived)
        const result = await db
            .select({ count: (0, drizzle_orm_1.sql) `count(*)` })
            .from(tables_1.applicationsTable)
            .where((0, drizzle_orm_1.sql) `is_archived = false`);
        const totalCount = result[0]?.count || 0;
        res.json({
            success: true,
            data: {
                count: totalCount,
            },
        });
    }
    catch (error) {
        logger_1.default.error(`Error fetching applications count: ${error}`);
        res.status(500).json({
            success: false,
            message: 'Failed to fetch applications count',
        });
    }
};
exports.getApplicationsCount = getApplicationsCount;
//# sourceMappingURL=get-applications-count.js.map