from app import create_app, db
from app.models.learning import VocationalContent

def seed_vocational_v4():
    app = create_app('development')
    with app.app_context():
        print("Starting Vocational V4 Seeding...")
        
        new_skills = [
            {
                "title": "Professional Tailoring",
                "description": "Master advanced garment construction and precision tailoring techniques for professional outfits.",
                "category": "Fashion",
                "language": "en",
                "resource_url": "https://www.youtube.com/embed/_ebOk8C1-po"
            },
            {
                "title": "Smartphone Hardware Repair",
                "description": "Learn how to diagnose and fix hardware issues, including screen replacements and motherboard repairs.",
                "category": "Technology",
                "language": "en",
                "resource_url": "https://www.youtube.com/embed/ZF952vYXK8o"
            },
            {
                "title": "Professional Catering",
                "description": "Learn the essentials of professional catering, large-scale food preparation, and Nigerian party delicacies.",
                "category": "Culinary",
                "language": "en",
                "resource_url": "https://www.youtube.com/embed/YrHpeEwk_-U"
            },
            {
                "title": "Modern Plumbing Basics",
                "description": "Foundational guide to household plumbing, pipe fittings, leak repairs, and modern installation standards.",
                "category": "Construction",
                "language": "en",
                "resource_url": "https://www.youtube.com/embed/8jxRn-T_LCs"
            },
            {
                "title": "Basic Home Wiring",
                "description": "Essential electrical safety and step-by-step instructions for basic residential wiring and socket installations.",
                "category": "Electrical",
                "language": "en",
                "resource_url": "https://www.youtube.com/embed/cX4s-bxn4fs"
            },
            {
                "title": "Furniture Crafting",
                "description": "Detailed guide to woodworking and building beautiful, durable household furniture from scratch.",
                "category": "Carpentry",
                "language": "en",
                "resource_url": "https://www.youtube.com/embed/QNgJjm0JX7Y"
            },
            {
                "title": "Fashion Illustration",
                "description": "Master the art of sketching fashion figures and translating your design ideas onto paper.",
                "category": "Fashion",
                "language": "en",
                "resource_url": "https://www.youtube.com/embed/S-LIQ3uZDEk"
            }
        ]

        for s_data in new_skills:
            # Check if already exists to avoid duplicates
            exists = VocationalContent.query.filter_by(title=s_data["title"], language=s_data["language"]).first()
            if exists:
                # Update URL if it already exists but we want to ensure it uses the new one
                exists.resource_url = s_data["resource_url"]
                exists.description = s_data["description"]
                exists.category = s_data["category"]
                print(f"Updated: {s_data['title']}")
            else:
                skill = VocationalContent(**s_data)
                db.session.add(skill)
                print(f"Added: {s_data['title']}")
        
        db.session.commit()
        print("Vocational V4 Seeding Complete.")

if __name__ == '__main__':
    seed_vocational_v4()
