"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("reflect-metadata");
const core_1 = require("@nestjs/core");
const common_1 = require("@nestjs/common");
const app_module_1 = require("../app.module");
const car_listing_service_1 = require("../appapi/carlisting/car-listing.service");
async function bootstrap() {
    const logger = new common_1.Logger("BackfillCarListingSpecFields");
    const batchSizeArg = Number(process.argv[2] || "");
    const batchSize = Number.isFinite(batchSizeArg) && batchSizeArg > 0 ? batchSizeArg : 200;
    const app = await core_1.NestFactory.createApplicationContext(app_module_1.AppModule, {
        logger: ["error", "warn", "log"],
    });
    try {
        const carListingService = app.get(car_listing_service_1.CarListingService);
        logger.log(`Backfilling car listing spec fields (batchSize=${batchSize})...`);
        const res = await carListingService.backfillCarListingSpecFields(batchSize);
        logger.log(`Backfill completed. Updated ${res.updated} listings.`);
    }
    finally {
        await app.close();
    }
}
bootstrap().catch((error) => {
    const logger = new common_1.Logger("BackfillCarListingSpecFields");
    logger.error(error?.message || "Backfill failed.", error?.stack);
    process.exit(1);
});
//# sourceMappingURL=backfill-car-listing-spec-fields.js.map