"""Seed the 21 students of Idealogy Academy."""
from django.core.management.base import BaseCommand

from exams.models import Student

STUDENTS = [
    # (code, name, class, tier)
    ("S-0001", "Ahmed Muddassar",  "9",    2),
    ("S-0002", "Shehryar",         "9",    2),
    ("S-0003", "Hamid Adil",       "9",    3),
    ("S-0004", "Rehan Shakeel",    "9",    2),
    ("S-0005", "Ali Hussain",      "9",    2),
    ("S-0006", "Hassan Kamran",    "9",    1),
    ("S-0007", "Siraj Qaisar",     "9", 4),
    ("S-0008", "Siraj Arslan",     "9", 4),
    ("S-0009", "Sahaheer Ashfaq",  "9", 5),
    ("S-0010", "Ubaid Ullah",      "9", 1),
    ("S-0011", "Hamza Mubashir",   "9", 5),
    ("S-0012", "Ammar Raza",       "9", 3),
    ("S-0013", "Talha Javed",      "9", 5),
    ("S-0014", "Abul Rehman",      "9", 4),
    ("S-0015", "Shahvaiz Sajid",   "9", 5),
    ("S-0016", "Ahmed Asif",       "9", 5),
    ("S-0017", "Aiman Ashraf",     "9",    1),
    ("S-0018", "Eman Faisal",      "9",    1),
    ("S-0019", "Aiman Nawaz",      "9",    2),
    ("S-0020", "Ifta",             "9",    3),
    ("S-0021", "Ayesha Abid",      "9",    3),
]


class Command(BaseCommand):
    help = "Seed the 21 Idealogy students"

    def handle(self, *args, **options):
        created = 0
        updated = 0
        for code, name, klass, tier in STUDENTS:
            obj, was_created = Student.objects.update_or_create(
                code=code,
                defaults={
                    'name': name,
                    'student_class': klass,
                    'tier': tier,
                    'shift': 'morning',
                },
            )
            if was_created:
                created += 1
            else:
                updated += 1
        self.stdout.write(self.style.SUCCESS(
            f"Done. Created: {created}, Updated: {updated}, Total: {Student.objects.count()}"
        ))
