

import django
import os
import sys
from datetime import date


# 30 fictional candidates, 2 per seeded JD (see seed_clients_jds.py).
# CTC values are in Lacs (the app renders "<value> Lacs"); notice_period is in days.
CANDIDATES = [
    # --- Senior Java Backend Developer (TechNova Solutions) ---
    {
        "first_name": "Arjun", "last_name": "Mehta",
        "email": "arjun.mehta91@gmail.com", "phone_number": "+919811045231",
        "date_of_birth": date(1991, 3, 14), "gender": "Male",
        "city": "Noida", "state": "Uttar Pradesh",
        "total_experience": "6.5", "current_company": "Infowave Technologies",
        "previous_company": "CodeCraft Systems", "current_role": "Senior Software Engineer",
        "current_ctc": "16.0", "expected_ctc": "22.0", "notice_period": 30,
        "current_location": "Noida", "preferred_location": "Noida",
        "highest_qualification": "B.Tech CSE", "university": "AKTU Lucknow",
        "passing_year": 2013, "percentage_cgpa": "78%",
        "availability": "30 Days", "status": "Verified", "source": "NAUKRI",
        "linkedin": "https://linkedin.com/in/arjun-mehta-java",
        "github": "https://github.com/arjunmehta91",
        "professional_summary": "Backend engineer with 6.5 years building high-throughput microservices for banking clients; led a 4-member team through a monolith-to-microservices migration.",
        "skills": ["Java", "Spring Boot", "Microservices", "Kafka", "PostgreSQL", "Redis", "Docker"],
        "languages": ["Hindi", "English"],
    },
    {
        "first_name": "Kavitha", "last_name": "Raman",
        "email": "kavitha.raman@outlook.com", "phone_number": "+919945078123",
        "date_of_birth": date(1990, 7, 22), "gender": "Female",
        "city": "Bengaluru", "state": "Karnataka",
        "total_experience": "7.0", "current_company": "Zentrix Software",
        "previous_company": "Mindtree", "current_role": "Lead Backend Developer",
        "current_ctc": "19.0", "expected_ctc": "24.0", "notice_period": 60,
        "current_location": "Bengaluru", "preferred_location": "Noida",
        "highest_qualification": "M.Tech CSE", "university": "Anna University",
        "passing_year": 2012, "percentage_cgpa": "8.4 CGPA",
        "availability": "60 Days", "status": "Profile Completed", "source": "LINKEDIN",
        "linkedin": "https://linkedin.com/in/kavitha-raman-dev",
        "professional_summary": "Lead developer with strong distributed-systems background; designed event-driven payment reconciliation processing 2M+ transactions/day.",
        "skills": ["Java", "Spring Boot", "Kafka", "AWS", "Kubernetes", "MySQL"],
        "languages": ["Tamil", "English", "Kannada"],
    },
    # --- DevOps Engineer (TechNova Solutions) ---
    {
        "first_name": "Rohit", "last_name": "Bansal",
        "email": "rohit.bansal.devops@gmail.com", "phone_number": "+919871733456",
        "date_of_birth": date(1995, 11, 2), "gender": "Male",
        "city": "Gurugram", "state": "Haryana",
        "total_experience": "4.0", "current_company": "CloudRidge Consulting",
        "previous_company": "HCL Technologies", "current_role": "DevOps Engineer",
        "current_ctc": "11.0", "expected_ctc": "16.0", "notice_period": 30,
        "current_location": "Gurugram", "preferred_location": "Noida",
        "highest_qualification": "B.Tech IT", "university": "Kurukshetra University",
        "passing_year": 2017, "percentage_cgpa": "72%",
        "availability": "30 Days", "status": "Verified", "source": "REFERRAL",
        "linkedin": "https://linkedin.com/in/rohit-bansal-devops",
        "github": "https://github.com/rohitbansal-ops",
        "professional_summary": "AWS-certified DevOps engineer; cut deployment time 70% by moving 30+ services to GitHub Actions with Terraform-managed EKS.",
        "skills": ["AWS", "Terraform", "Jenkins", "Docker", "Kubernetes", "Linux", "Python"],
        "languages": ["Hindi", "English"],
    },
    {
        "first_name": "Sneha", "last_name": "Kulkarni",
        "email": "sneha.kulkarni.sre@gmail.com", "phone_number": "+919890561234",
        "date_of_birth": date(1996, 4, 18), "gender": "Female",
        "city": "Pune", "state": "Maharashtra",
        "total_experience": "3.5", "current_company": "Nimbus Cloud Labs",
        "previous_company": "Tech Mahindra", "current_role": "Site Reliability Engineer",
        "current_ctc": "10.5", "expected_ctc": "14.5", "notice_period": 15,
        "current_location": "Pune", "preferred_location": "Remote / Noida",
        "highest_qualification": "B.E. Computer", "university": "Savitribai Phule Pune University",
        "passing_year": 2018, "percentage_cgpa": "8.1 CGPA",
        "availability": "15 Days", "status": "Profile Completed", "source": "NAUKRI",
        "linkedin": "https://linkedin.com/in/sneha-kulkarni-sre",
        "professional_summary": "SRE focused on observability and infra-as-code; built Prometheus/Grafana monitoring covering 200+ containers.",
        "skills": ["AWS", "Ansible", "Docker", "Kubernetes", "Prometheus", "Grafana", "Bash"],
        "languages": ["Marathi", "Hindi", "English"],
    },
    # --- Credit Risk Analyst (FinEdge Capital) ---
    {
        "first_name": "Ananya", "last_name": "Iyer",
        "email": "ananya.iyer.fin@gmail.com", "phone_number": "+919820455678",
        "date_of_birth": date(1994, 9, 30), "gender": "Female",
        "city": "Mumbai", "state": "Maharashtra",
        "total_experience": "3.0", "current_company": "Crestline Finance",
        "previous_company": "Bajaj Finserv", "current_role": "Risk Analyst",
        "current_ctc": "9.0", "expected_ctc": "12.0", "notice_period": 60,
        "current_location": "Mumbai", "preferred_location": "Mumbai",
        "highest_qualification": "MBA Finance", "university": "NMIMS Mumbai",
        "passing_year": 2019, "percentage_cgpa": "3.5/4 GPA",
        "availability": "60 Days", "status": "Verified", "source": "LINKEDIN",
        "linkedin": "https://linkedin.com/in/ananya-iyer-risk",
        "professional_summary": "Credit risk analyst managing a Rs 400 Cr retail lending portfolio; built early-warning triggers that reduced 90+ DPD by 12%.",
        "skills": ["Credit Underwriting", "SQL", "Excel", "Power BI", "Financial Modelling"],
        "languages": ["English", "Hindi", "Tamil"],
    },
    {
        "first_name": "Farhan", "last_name": "Qureshi",
        "email": "farhan.q.analyst@gmail.com", "phone_number": "+919930244987",
        "date_of_birth": date(1996, 1, 25), "gender": "Male",
        "city": "Thane", "state": "Maharashtra",
        "total_experience": "2.5", "current_company": "Meridian NBFC",
        "previous_company": None, "current_role": "Junior Credit Analyst",
        "current_ctc": "7.5", "expected_ctc": "10.0", "notice_period": 30,
        "current_location": "Thane", "preferred_location": "Mumbai",
        "highest_qualification": "CA Inter", "university": "ICAI",
        "passing_year": 2020, "percentage_cgpa": "61%",
        "availability": "30 Days", "status": "Draft", "source": "UPLOAD",
        "linkedin": "https://linkedin.com/in/farhan-qureshi-credit",
        "professional_summary": "CA Inter with hands-on SME credit appraisal experience across 150+ files; strong in ratio analysis and banker negotiation.",
        "skills": ["Financial Statement Analysis", "Excel", "SQL", "Credit Appraisal"],
        "languages": ["Hindi", "English", "Urdu"],
    },
    # --- Full Stack Developer React+Node (FinEdge Capital) ---
    {
        "first_name": "Priya", "last_name": "Nair",
        "email": "priya.nair.dev@gmail.com", "phone_number": "+919892211345",
        "date_of_birth": date(1993, 12, 8), "gender": "Female",
        "city": "Mumbai", "state": "Maharashtra",
        "total_experience": "4.5", "current_company": "PixelWorks Digital",
        "previous_company": "Capgemini", "current_role": "Full Stack Developer",
        "current_ctc": "13.0", "expected_ctc": "18.0", "notice_period": 30,
        "current_location": "Mumbai", "preferred_location": "Mumbai",
        "highest_qualification": "B.E. IT", "university": "Mumbai University",
        "passing_year": 2015, "percentage_cgpa": "74%",
        "availability": "30 Days", "status": "Verified", "source": "SELF",
        "linkedin": "https://linkedin.com/in/priya-nair-fullstack",
        "github": "https://github.com/priyanair-dev",
        "professional_summary": "Full stack developer who shipped three customer-facing fintech portals end-to-end; comfortable owning features from schema to UI.",
        "skills": ["React", "Node.js", "TypeScript", "MongoDB", "REST APIs", "Jest"],
        "languages": ["Malayalam", "Hindi", "English"],
    },
    {
        "first_name": "Deepak", "last_name": "Verma",
        "email": "deepak.verma.js@gmail.com", "phone_number": "+919765588210",
        "date_of_birth": date(1992, 6, 15), "gender": "Male",
        "city": "Pune", "state": "Maharashtra",
        "total_experience": "5.0", "current_company": "Softbridge Solutions",
        "previous_company": "Wipro", "current_role": "Senior MERN Developer",
        "current_ctc": "15.0", "expected_ctc": "20.0", "notice_period": 0,
        "current_location": "Pune", "preferred_location": "Mumbai",
        "highest_qualification": "MCA", "university": "Pune University",
        "passing_year": 2015, "percentage_cgpa": "7.9 CGPA",
        "availability": "Immediate", "status": "Profile Completed", "source": "NAUKRI",
        "linkedin": "https://linkedin.com/in/deepak-verma-mern",
        "github": "https://github.com/deepakverma-js",
        "professional_summary": "Serving notice; senior MERN developer with lending-domain experience - built loan origination flows handling 50k applications/month.",
        "skills": ["React", "Next.js", "Node.js", "TypeScript", "PostgreSQL", "GraphQL", "AWS Lambda"],
        "languages": ["Hindi", "Marathi", "English"],
    },
    # --- Clinical Data Analyst (MediCore Health) ---
    {
        "first_name": "Ritika", "last_name": "Shah",
        "email": "ritika.shah.health@gmail.com", "phone_number": "+919949322876",
        "date_of_birth": date(1995, 8, 11), "gender": "Female",
        "city": "Hyderabad", "state": "Telangana",
        "total_experience": "3.0", "current_company": "LifeLine Hospitals",
        "previous_company": "Apollo Pharmacy - Analytics", "current_role": "Data Analyst",
        "current_ctc": "6.5", "expected_ctc": "9.0", "notice_period": 30,
        "current_location": "Hyderabad", "preferred_location": "Hyderabad",
        "highest_qualification": "B.Pharm", "university": "Osmania University",
        "passing_year": 2017, "percentage_cgpa": "8.0 CGPA",
        "availability": "30 Days", "status": "Profile Completed", "source": "LINKEDIN",
        "linkedin": "https://linkedin.com/in/ritika-shah-healthdata",
        "professional_summary": "Healthcare analyst building bed-occupancy and OT-utilization dashboards for a 600-bed hospital chain; familiar with HL7 feeds.",
        "skills": ["SQL", "Excel", "Tableau", "HL7", "Healthcare Reporting"],
        "languages": ["Hindi", "English", "Telugu"],
    },
    {
        "first_name": "Joseph", "last_name": "Thomas",
        "email": "joseph.thomas.da@gmail.com", "phone_number": "+919847066123",
        "date_of_birth": date(1993, 2, 27), "gender": "Male",
        "city": "Kochi", "state": "Kerala",
        "total_experience": "4.0", "current_company": "Medway Research",
        "previous_company": "Lakeshore Hospital", "current_role": "Clinical Data Coordinator",
        "current_ctc": "8.0", "expected_ctc": "10.5", "notice_period": 60,
        "current_location": "Kochi", "preferred_location": "Hyderabad",
        "highest_qualification": "M.Sc Biostatistics", "university": "Kerala University",
        "passing_year": 2016, "percentage_cgpa": "7.6 CGPA",
        "availability": "60 Days", "status": "Draft", "source": "UPLOAD",
        "linkedin": "https://linkedin.com/in/joseph-thomas-clinical",
        "professional_summary": "Biostatistician managing EDC datasets for multi-site trials; wrote Python validation scripts that cut query resolution time by half.",
        "skills": ["SQL", "Python", "Clinical Data Management", "FHIR", "Power BI"],
        "languages": ["Malayalam", "English"],
    },
    # --- Flutter Mobile Developer (MediCore Health) ---
    {
        "first_name": "Vikram", "last_name": "Reddy",
        "email": "vikram.reddy.flutter@gmail.com", "phone_number": "+919618144532",
        "date_of_birth": date(1994, 10, 5), "gender": "Male",
        "city": "Hyderabad", "state": "Telangana",
        "total_experience": "4.0", "current_company": "Appfinity Labs",
        "previous_company": "Cognizant", "current_role": "Mobile Developer",
        "current_ctc": "11.0", "expected_ctc": "15.0", "notice_period": 0,
        "current_location": "Hyderabad", "preferred_location": "Hyderabad",
        "highest_qualification": "B.Tech CSE", "university": "JNTU Hyderabad",
        "passing_year": 2016, "percentage_cgpa": "71%",
        "availability": "Immediate", "status": "Verified", "source": "REFERRAL",
        "linkedin": "https://linkedin.com/in/vikram-reddy-mobile",
        "github": "https://github.com/vikramreddy-flutter",
        "professional_summary": "Flutter developer with 4 published apps (500k+ combined installs), including a doctor-consult app with Agora video integration. Immediately available.",
        "skills": ["Flutter", "Dart", "Firebase", "Bloc", "REST APIs"],
        "languages": ["Telugu", "Hindi", "English"],
    },
    {
        "first_name": "Ishita", "last_name": "Malhotra",
        "email": "ishita.malhotra.app@gmail.com", "phone_number": "+919829077654",
        "date_of_birth": date(1997, 5, 19), "gender": "Female",
        "city": "Jaipur", "state": "Rajasthan",
        "total_experience": "3.0", "current_company": "TechSprout Studio",
        "previous_company": "Freelance", "current_role": "Flutter Developer",
        "current_ctc": "9.5", "expected_ctc": "13.0", "notice_period": 15,
        "current_location": "Jaipur", "preferred_location": "Hyderabad / Remote",
        "highest_qualification": "B.Tech CSE", "university": "Rajasthan Technical University",
        "passing_year": 2019, "percentage_cgpa": "8.6 CGPA",
        "availability": "15 Days", "status": "Profile Completed", "source": "LINKEDIN",
        "linkedin": "https://linkedin.com/in/ishita-malhotra-flutter",
        "github": "https://github.com/ishitamalhotra",
        "portfolio": "https://ishitamalhotra.dev",
        "professional_summary": "Product-minded Flutter developer; built an offline-first field-health data app used by 2,000 ASHA workers.",
        "skills": ["Flutter", "Dart", "Riverpod", "Firebase", "SQLite"],
        "languages": ["Hindi", "English"],
    },
    # --- IoT Firmware Engineer (GreenGrid Energy) ---
    {
        "first_name": "Suresh", "last_name": "Palani",
        "email": "suresh.palani.embedded@gmail.com", "phone_number": "+919884421309",
        "date_of_birth": date(1991, 1, 12), "gender": "Male",
        "city": "Chennai", "state": "Tamil Nadu",
        "total_experience": "5.5", "current_company": "VoltEdge Systems",
        "previous_company": "Bosch India", "current_role": "Senior Firmware Engineer",
        "current_ctc": "14.0", "expected_ctc": "19.0", "notice_period": 45,
        "current_location": "Chennai", "preferred_location": "Chennai",
        "highest_qualification": "M.E. Embedded Systems", "university": "Anna University",
        "passing_year": 2014, "percentage_cgpa": "8.2 CGPA",
        "availability": "60 Days", "status": "Verified", "source": "NAUKRI",
        "linkedin": "https://linkedin.com/in/suresh-palani-embedded",
        "professional_summary": "Firmware engineer with energy-sector experience - shipped smart-meter firmware with OTA updates deployed to 80k devices.",
        "skills": ["Embedded C", "FreeRTOS", "MQTT", "Modbus", "ESP32", "STM32", "LoRaWAN"],
        "languages": ["Tamil", "English"],
    },
    {
        "first_name": "Meghna", "last_name": "Bose",
        "email": "meghna.bose.iot@gmail.com", "phone_number": "+919830155842",
        "date_of_birth": date(1993, 11, 23), "gender": "Female",
        "city": "Kolkata", "state": "West Bengal",
        "total_experience": "4.5", "current_company": "Kinetix Automation",
        "previous_company": "Havells R&D", "current_role": "Embedded Engineer",
        "current_ctc": "12.5", "expected_ctc": "17.0", "notice_period": 30,
        "current_location": "Kolkata", "preferred_location": "Chennai",
        "highest_qualification": "B.Tech ECE", "university": "Jadavpur University",
        "passing_year": 2015, "percentage_cgpa": "8.8 CGPA",
        "availability": "30 Days", "status": "Profile Completed", "source": "LINKEDIN",
        "linkedin": "https://linkedin.com/in/meghna-bose-embedded",
        "professional_summary": "Embedded engineer across consumer IoT and industrial automation; strong hardware-debug skills, owns firmware from bring-up to certification.",
        "skills": ["Embedded C", "C++", "RTOS", "MQTT", "PCB Debugging", "ESP32", "Zigbee"],
        "languages": ["Bengali", "Hindi", "English"],
    },
    # --- Site Operations Manager (GreenGrid Energy) ---
    {
        "first_name": "Rajendra", "last_name": "Chaudhary",
        "email": "rajendra.chaudhary.ops@gmail.com", "phone_number": "+919414188976",
        "date_of_birth": date(1987, 4, 2), "gender": "Male",
        "city": "Jodhpur", "state": "Rajasthan",
        "total_experience": "8.0", "current_company": "SunTrack Renewables",
        "previous_company": "Adani Green", "current_role": "Deputy Manager O&M",
        "current_ctc": "11.0", "expected_ctc": "14.5", "notice_period": 60,
        "current_location": "Jodhpur", "preferred_location": "Jaisalmer",
        "highest_qualification": "B.Tech Electrical", "university": "MBM Engineering College Jodhpur",
        "passing_year": 2009, "percentage_cgpa": "68%",
        "availability": "60 Days", "status": "Verified", "source": "REFERRAL",
        "linkedin": "https://linkedin.com/in/rajendra-chaudhary-solar",
        "professional_summary": "8 years in solar O&M, currently running a 90 MW site with a 25-member team; NEBOSH IGC certified, comfortable with desert postings.",
        "skills": ["Solar O&M", "SCADA", "HSE Compliance", "Vendor Management", "Team Leadership"],
        "languages": ["Hindi", "Rajasthani", "English"],
    },
    {
        "first_name": "Harpreet Singh", "last_name": "Gill",
        "email": "harpreet.gill.energy@gmail.com", "phone_number": "+919815533421",
        "date_of_birth": date(1989, 8, 16), "gender": "Male",
        "city": "Bikaner", "state": "Rajasthan",
        "total_experience": "7.0", "current_company": "DesertSun Power",
        "previous_company": "Suzlon", "current_role": "Shift In-charge",
        "current_ctc": "10.0", "expected_ctc": "13.0", "notice_period": 90,
        "current_location": "Bikaner", "preferred_location": "Jaisalmer",
        "highest_qualification": "B.Tech Mechanical", "university": "Punjab Technical University",
        "passing_year": 2011, "percentage_cgpa": "70%",
        "availability": "90 Days", "status": "Draft", "source": "UPLOAD",
        "linkedin": "https://linkedin.com/in/harpreet-gill-om",
        "professional_summary": "O&M professional across wind and solar assets; led preventive-maintenance program that lifted plant availability to 99.2%.",
        "skills": ["Solar O&M", "Preventive Maintenance", "Grid Compliance", "Contractor Management"],
        "languages": ["Punjabi", "Hindi", "English"],
    },
    # --- Product Manager - POS Platform (ShopSphere Retail) ---
    {
        "first_name": "Nandini", "last_name": "Krishnan",
        "email": "nandini.krishnan.pm@gmail.com", "phone_number": "+919886012459",
        "date_of_birth": date(1992, 3, 9), "gender": "Female",
        "city": "Bengaluru", "state": "Karnataka",
        "total_experience": "6.0", "current_company": "RetailLoop SaaS",
        "previous_company": "Swiggy", "current_role": "Product Manager",
        "current_ctc": "26.0", "expected_ctc": "34.0", "notice_period": 60,
        "current_location": "Bengaluru", "preferred_location": "Bengaluru",
        "highest_qualification": "MBA", "university": "IIM Kozhikode",
        "passing_year": 2016, "percentage_cgpa": "3.6/4 GPA",
        "availability": "60 Days", "status": "Verified", "source": "LINKEDIN",
        "linkedin": "https://linkedin.com/in/nandini-krishnan-product",
        "professional_summary": "PM who took a merchant billing product from 0 to 1 to Rs 8 Cr ARR; deep in retail-tech, runs discovery directly with store owners.",
        "skills": ["Product Roadmapping", "B2B SaaS", "SQL", "A/B Testing", "Stakeholder Management"],
        "languages": ["English", "Tamil", "Kannada", "Hindi"],
    },
    {
        "first_name": "Aditya", "last_name": "Kapoor",
        "email": "aditya.kapoor.prod@gmail.com", "phone_number": "+919810090876",
        "date_of_birth": date(1990, 12, 1), "gender": "Male",
        "city": "Delhi", "state": "Delhi",
        "total_experience": "7.5", "current_company": "Paylite Commerce",
        "previous_company": "Zomato", "current_role": "Senior Product Manager",
        "current_ctc": "28.0", "expected_ctc": "36.0", "notice_period": 60,
        "current_location": "Delhi", "preferred_location": "Bengaluru",
        "highest_qualification": "PGDM", "university": "MDI Gurgaon",
        "passing_year": 2014, "percentage_cgpa": "7.8 CGPA",
        "availability": "60 Days", "status": "Profile Completed", "source": "REFERRAL",
        "linkedin": "https://linkedin.com/in/aditya-kapoor-pm",
        "professional_summary": "Senior PM with payments and POS domain depth; scaled an SMB POS product to 12k merchants, CSPO certified, open to relocation.",
        "skills": ["Product Strategy", "POS/Payments Domain", "Experimentation", "OKRs"],
        "languages": ["Hindi", "English"],
    },
    # --- QA Automation Engineer (ShopSphere Retail) ---
    {
        "first_name": "Divya", "last_name": "Menon",
        "email": "divya.menon.qa@gmail.com", "phone_number": "+919632244190",
        "date_of_birth": date(1996, 6, 28), "gender": "Female",
        "city": "Bengaluru", "state": "Karnataka",
        "total_experience": "3.0", "current_company": "TestHive Technologies",
        "previous_company": "Accenture", "current_role": "QA Engineer",
        "current_ctc": "7.5", "expected_ctc": "10.5", "notice_period": 30,
        "current_location": "Bengaluru", "preferred_location": "Bengaluru",
        "highest_qualification": "B.E. CSE", "university": "VTU",
        "passing_year": 2018, "percentage_cgpa": "8.3 CGPA",
        "availability": "30 Days", "status": "Verified", "source": "NAUKRI",
        "linkedin": "https://linkedin.com/in/divya-menon-qa",
        "github": "https://github.com/divyamenon-qa",
        "professional_summary": "Automation engineer, ISTQB certified; built a Playwright framework from scratch reaching 75% regression coverage for an e-commerce client.",
        "skills": ["Playwright", "Java", "Selenium", "RestAssured", "Git", "Jenkins"],
        "languages": ["Malayalam", "English", "Kannada"],
    },
    {
        "first_name": "Sameer", "last_name": "Joshi",
        "email": "sameer.joshi.sdet@gmail.com", "phone_number": "+919741182653",
        "date_of_birth": date(1997, 9, 14), "gender": "Male",
        "city": "Mysuru", "state": "Karnataka",
        "total_experience": "2.5", "current_company": "QualityFirst Labs",
        "previous_company": None, "current_role": "SDET",
        "current_ctc": "6.5", "expected_ctc": "9.0", "notice_period": 15,
        "current_location": "Mysuru", "preferred_location": "Bengaluru",
        "highest_qualification": "B.E. ISE", "university": "Mysore University",
        "passing_year": 2020, "percentage_cgpa": "7.7 CGPA",
        "availability": "15 Days", "status": "Profile Completed", "source": "SELF",
        "linkedin": "https://linkedin.com/in/sameer-joshi-sdet",
        "professional_summary": "SDET with 2.5 years across web, API and mobile automation; added JMeter load suites that caught two pre-release performance regressions.",
        "skills": ["Selenium", "Python", "API Testing", "Postman", "JMeter", "Appium"],
        "languages": ["Hindi", "English", "Kannada"],
    },
    # --- Fleet Data Scientist (Quantum Logistics) ---
    {
        "first_name": "Tanvi", "last_name": "Desai",
        "email": "tanvi.desai.ds@gmail.com", "phone_number": "+919819834012",
        "date_of_birth": date(1994, 2, 20), "gender": "Female",
        "city": "Gurugram", "state": "Haryana",
        "total_experience": "4.0", "current_company": "MoveMetrics Analytics",
        "previous_company": "Delhivery", "current_role": "Data Scientist",
        "current_ctc": "15.0", "expected_ctc": "21.0", "notice_period": 30,
        "current_location": "Gurugram", "preferred_location": "Gurugram",
        "highest_qualification": "M.Tech CS", "university": "IIIT Delhi",
        "passing_year": 2018, "percentage_cgpa": "8.9 CGPA",
        "availability": "30 Days", "status": "Verified", "source": "LINKEDIN",
        "linkedin": "https://linkedin.com/in/tanvi-desai-ds",
        "github": "https://github.com/tanvidesai-ml",
        "professional_summary": "Data scientist in logistics; shipped an ETA model (XGBoost + map-matching) that improved on-time-delivery prediction accuracy by 18%.",
        "skills": ["Python", "Machine Learning", "SQL", "Geospatial Analytics", "PySpark"],
        "languages": ["Gujarati", "Hindi", "English"],
    },
    {
        "first_name": "Abhishek", "last_name": "Rana",
        "email": "abhishek.rana.ml@gmail.com", "phone_number": "+919897366504",
        "date_of_birth": date(1993, 7, 7), "gender": "Male",
        "city": "Noida", "state": "Uttar Pradesh",
        "total_experience": "5.0", "current_company": "FreightFlow Tech",
        "previous_company": "Ola", "current_role": "Senior Data Scientist",
        "current_ctc": "17.0", "expected_ctc": "22.0", "notice_period": 60,
        "current_location": "Noida", "preferred_location": "Gurugram",
        "highest_qualification": "M.Sc Statistics", "university": "Delhi University",
        "passing_year": 2016, "percentage_cgpa": "76%",
        "availability": "60 Days", "status": "Profile Completed", "source": "NAUKRI",
        "linkedin": "https://linkedin.com/in/abhishek-rana-datascience",
        "professional_summary": "Senior DS specializing in route optimization and dispatch algorithms; reduced per-package delivery cost 9% via zone-rebalancing models.",
        "skills": ["Python", "Route Optimization", "OR-Tools", "SQL", "MLOps", "Airflow"],
        "languages": ["Hindi", "English"],
    },
    # --- Academic Counselor (EduBridge Learning) ---
    {
        "first_name": "Pooja", "last_name": "Sharma",
        "email": "pooja.sharma.edu@gmail.com", "phone_number": "+919971120348",
        "date_of_birth": date(1998, 4, 25), "gender": "Female",
        "city": "Delhi", "state": "Delhi",
        "total_experience": "2.0", "current_company": "SkillRise Academy",
        "previous_company": "BYJU'S", "current_role": "Admission Counselor",
        "current_ctc": "4.2", "expected_ctc": "5.5", "notice_period": 0,
        "current_location": "Delhi", "preferred_location": "Delhi NCR",
        "highest_qualification": "B.A. Psychology", "university": "Delhi University",
        "passing_year": 2019, "percentage_cgpa": "72%",
        "availability": "Immediate", "status": "Verified", "source": "NAUKRI",
        "linkedin": "https://linkedin.com/in/pooja-sharma-counselor",
        "professional_summary": "Counselor consistently at 110%+ of enrollment targets; comfortable with Tue-Sun roster and walk-in plus tele-counseling mix. Immediately available.",
        "skills": ["Inside Sales", "Counseling", "LeadSquared CRM", "Communication"],
        "languages": ["Hindi", "English"],
    },
    {
        "first_name": "Mohit", "last_name": "Aggarwal",
        "email": "mohit.aggarwal.sales@gmail.com", "phone_number": "+918860274519",
        "date_of_birth": date(1999, 10, 31), "gender": "Male",
        "city": "Ghaziabad", "state": "Uttar Pradesh",
        "total_experience": "1.5", "current_company": "LearnKart",
        "previous_company": None, "current_role": "Business Development Associate",
        "current_ctc": "3.8", "expected_ctc": "5.0", "notice_period": 15,
        "current_location": "Ghaziabad", "preferred_location": "Delhi NCR",
        "highest_qualification": "B.Com", "university": "CCS University",
        "passing_year": 2021, "percentage_cgpa": "65%",
        "availability": "15 Days", "status": "Draft", "source": "SELF",
        "linkedin": "https://linkedin.com/in/mohit-aggarwal-bda",
        "professional_summary": "1.5 years in edtech tele-sales with strong follow-up discipline; averages 80+ dials/day, best month Rs 11L revenue.",
        "skills": ["Tele-sales", "Lead Follow-up", "Zoho CRM", "Objection Handling"],
        "languages": ["Hindi", "English"],
    },
    # --- SOC Analyst L2 (SecureStack Cyber) ---
    {
        "first_name": "Neha", "last_name": "Kulshreshtha",
        "email": "neha.k.security@gmail.com", "phone_number": "+919823247761",
        "date_of_birth": date(1994, 12, 13), "gender": "Female",
        "city": "Pune", "state": "Maharashtra",
        "total_experience": "4.0", "current_company": "CyberShield MSSP",
        "previous_company": "TCS", "current_role": "SOC Analyst",
        "current_ctc": "10.0", "expected_ctc": "13.5", "notice_period": 30,
        "current_location": "Pune", "preferred_location": "Pune",
        "highest_qualification": "B.Tech IT", "university": "VIT Pune",
        "passing_year": 2016, "percentage_cgpa": "8.0 CGPA",
        "availability": "30 Days", "status": "Verified", "source": "LINKEDIN",
        "linkedin": "https://linkedin.com/in/neha-kulshreshtha-soc",
        "professional_summary": "SOC analyst (CEH) handling L2 escalations in a 24x7 MSSP; wrote 40+ Splunk correlation rules and mentors a 3-member L1 pod. Fine with night shifts.",
        "skills": ["Splunk", "SIEM Tuning", "MITRE ATT&CK", "Incident Response", "Python"],
        "languages": ["Hindi", "Marathi", "English"],
    },
    {
        "first_name": "Karthik", "last_name": "Subramanian",
        "email": "karthik.subra.sec@gmail.com", "phone_number": "+919500138264",
        "date_of_birth": date(1995, 5, 6), "gender": "Male",
        "city": "Chennai", "state": "Tamil Nadu",
        "total_experience": "3.5", "current_company": "NetSentry Solutions",
        "previous_company": "Wipro CDC", "current_role": "Security Analyst",
        "current_ctc": "8.5", "expected_ctc": "12.0", "notice_period": 30,
        "current_location": "Chennai", "preferred_location": "Pune",
        "highest_qualification": "B.Sc IT", "university": "Madras University",
        "passing_year": 2017, "percentage_cgpa": "74%",
        "availability": "30 Days", "status": "Profile Completed", "source": "REFERRAL",
        "linkedin": "https://linkedin.com/in/karthik-subramanian-sec",
        "professional_summary": "Security+ certified analyst with QRadar depth and hands-on SOAR playbook building; led triage during a ransomware tabletop that became policy.",
        "skills": ["QRadar", "Log Analysis", "Threat Hunting", "SOAR"],
        "languages": ["Tamil", "English"],
    },
    # --- CNC Programmer - Aerospace (AeroWorks Engineering) ---
    {
        "first_name": "Ganesh", "last_name": "Pawar",
        "email": "ganesh.pawar.cnc@gmail.com", "phone_number": "+919822015437",
        "date_of_birth": date(1990, 9, 3), "gender": "Male",
        "city": "Pune", "state": "Maharashtra",
        "total_experience": "6.0", "current_company": "Precitech Components",
        "previous_company": "Bharat Forge", "current_role": "Senior CNC Programmer",
        "current_ctc": "7.0", "expected_ctc": "9.5", "notice_period": 30,
        "current_location": "Pune", "preferred_location": "Pune",
        "highest_qualification": "Diploma Mechanical", "college": "Government Polytechnic Pune",
        "passing_year": 2010, "percentage_cgpa": "70%",
        "availability": "30 Days", "status": "Verified", "source": "REFERRAL",
        "professional_summary": "CNC programmer with 6 years on 5-axis DMG MORI machines; machined titanium aerospace brackets under AS9100 with FAI documentation ownership.",
        "skills": ["Fanuc", "5-Axis Machining", "Mastercam", "GD&T", "First Article Inspection"],
        "languages": ["Marathi", "Hindi", "English"],
    },
    {
        "first_name": "Santosh", "last_name": "Kamble",
        "email": "santosh.kamble.cam@gmail.com", "phone_number": "+919766390218",
        "date_of_birth": date(1992, 1, 17), "gender": "Male",
        "city": "Nashik", "state": "Maharashtra",
        "total_experience": "5.0", "current_company": "Accura Machining Works",
        "previous_company": "Mahindra Aerospace vendor unit", "current_role": "CNC Programmer",
        "current_ctc": "6.0", "expected_ctc": "8.5", "notice_period": 30,
        "current_location": "Nashik", "preferred_location": "Pune",
        "highest_qualification": "B.Tech Production", "university": "Pune University",
        "passing_year": 2014, "percentage_cgpa": "66%",
        "availability": "30 Days", "status": "Profile Completed", "source": "UPLOAD",
        "professional_summary": "Programmer experienced in Inconel and stainless aero components; reduced cycle time 15% on a landing-gear part through toolpath optimization.",
        "skills": ["Siemens 840D", "NX CAM", "5-Axis Machining", "Inconel Machining", "GD&T"],
        "languages": ["Marathi", "Hindi"],
    },
    # --- Performance Marketing Lead (BlueOrbit Media) ---
    {
        "first_name": "Aishwarya", "last_name": "Rao",
        "email": "aishwarya.rao.growth@gmail.com", "phone_number": "+919986147730",
        "date_of_birth": date(1993, 6, 21), "gender": "Female",
        "city": "Bengaluru", "state": "Karnataka",
        "total_experience": "5.0", "current_company": "AdVantage Digital",
        "previous_company": "Lenskart", "current_role": "Performance Marketing Manager",
        "current_ctc": "13.0", "expected_ctc": "17.5", "notice_period": 45,
        "current_location": "Bengaluru", "preferred_location": "Bengaluru",
        "highest_qualification": "MBA Marketing", "university": "Christ University",
        "passing_year": 2017, "percentage_cgpa": "3.4/4 GPA",
        "availability": "60 Days", "status": "Verified", "source": "LINKEDIN",
        "linkedin": "https://linkedin.com/in/aishwarya-rao-growth",
        "professional_summary": "Growth marketer managing Rs 75L/month across Google and Meta for D2C brands at 3.2x blended ROAS; Google Ads certified, leads a team of 3.",
        "skills": ["Google Ads", "Meta Ads", "GA4", "ROAS Optimization", "Team Leadership", "DV360"],
        "languages": ["English", "Kannada", "Hindi"],
    },
    {
        "first_name": "Varun", "last_name": "Chopra",
        "email": "varun.chopra.ppc@gmail.com", "phone_number": "+919821658091",
        "date_of_birth": date(1994, 11, 11), "gender": "Male",
        "city": "Mumbai", "state": "Maharashtra",
        "total_experience": "4.5", "current_company": "ClickCraft Media",
        "previous_company": "Publicis", "current_role": "Senior PPC Specialist",
        "current_ctc": "11.5", "expected_ctc": "16.0", "notice_period": 30,
        "current_location": "Mumbai", "preferred_location": "Bengaluru",
        "highest_qualification": "B.M.S.", "university": "Mumbai University",
        "passing_year": 2016, "percentage_cgpa": "71%",
        "availability": "30 Days", "status": "Profile Completed", "source": "NAUKRI",
        "linkedin": "https://linkedin.com/in/varun-chopra-ppc",
        "professional_summary": "PPC specialist who scaled a consumer-electronics account from Rs 20L to Rs 60L monthly spend while holding CPA flat; strong on landing-page CRO.",
        "skills": ["Google Ads", "Meta Ads", "GA4", "CRO", "Marketing Automation"],
        "languages": ["Hindi", "English", "Punjabi"],
    },
]


def seed_data(stdout=None):
    from apps.candidates.models import Candidate, Skill, Language
    from apps.users.models import User

    def log(message):
        if stdout:
            stdout.write(message)
        else:
            print(message)

    # created_by for seeded candidates: the demo admin, else any superuser.
    creator = (
        User.objects.filter(email="ats@admin.com").first()
        or User.objects.filter(is_superuser=True).first()
    )
    if not creator:
        log("ERROR: No admin/superuser found. Run seed_demo_users.py first.")
        return

    created_count = updated_count = 0
    for data in CANDIDATES:
        skills = data.pop("skills", [])
        languages = data.pop("languages", [])
        email = data.pop("email")

        defaults = {
            "country": "India",
            "fresher": False,
            "employment_type": "Full Time",
            "created_by": creator,
            "updated_by": creator,
            **data,
        }
        # Include soft-deleted rows so re-running revives instead of duplicating.
        candidate, created = Candidate.objects.all_with_deleted().update_or_create(
            email=email,
            defaults={**defaults, "is_active": True, "is_deleted": False},
        )

        skill_objs = [Skill.objects.get_or_create(name=s)[0] for s in skills]
        language_objs = [Language.objects.get_or_create(name=l)[0] for l in languages]
        candidate.skills.set(skill_objs)
        candidate.languages.set(language_objs)

        # pop() above mutated CANDIDATES; put keys back so a repeated
        # seed_data() call in the same process still works.
        data["skills"], data["languages"], data["email"] = skills, languages, email

        if created:
            created_count += 1
        else:
            updated_count += 1
        log(f"{'Created' if created else 'Updated'} candidate: {candidate.first_name} {candidate.last_name} ({email})")

    log("Candidate seeding completed successfully!")
    log(f"Created: {created_count}, Updated: {updated_count}")
    log(f"Totals now in DB: {Candidate.objects.count()} candidates, "
        f"{Skill.objects.count()} skills, {Language.objects.count()} languages")


if __name__ == "__main__":
    # Set up Django
    sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.dev")
    django.setup()

    seed_data()
