import "dotenv/config";
import { connectDatabase } from "./src/db/mongoose.js";
import { JobModel } from "./src/models/job.model.js";

async function checkJobsStatus() {
  try {
    await connectDatabase();
    console.log("\n=== Checking Job Statuses ===\n");
    
    const jobs = await JobModel.find({}).lean();
    console.log(`Total jobs in database: ${jobs.length}\n`);
    
    const published = jobs.filter(j => j.status === "Published");
    const draft = jobs.filter(j => j.status === "Draft");
    
    console.log(`Published jobs: ${published.length}`);
    published.forEach(j => {
      console.log(`  ✓ ${j.title} (${j.department})`);
    });
    
    console.log(`\nDraft jobs: ${draft.length}`);
    draft.forEach(j => {
      console.log(`  ✗ ${j.title} (${j.department})`);
    });
    
    console.log("\n=== Summary ===");
    console.log(`Only Published jobs appear on the frontend Careers page.`);
    console.log(`To make Draft jobs visible, change their status to "Published" in the admin panel.\n`);
    
    process.exit(0);
  } catch (error) {
    console.error("Error:", error);
    process.exit(1);
  }
}

checkJobsStatus();







