# from django.apps import AppConfig


# class MyappConfig(AppConfig):
#     default_auto_field = 'django.db.models.BigAutoField'
#     name = 'myapp'
from django.apps import AppConfig


class MyappConfig(AppConfig):
    # ? 'yourapp' ?????? ?????? actual app name-?? ???????????
    name = 'myapp'

    def ready(self):
        """
        Server start ????????? ????? face encodings-????? memory-?? load ???????.
        ?????? ????? attendance request ??? fast-?? ?????.
        """
        import threading

        def preload():
            try:
                # Import here to avoid circular import
                from .views import load_encoding_cache
                load_encoding_cache(force=True)
                print("[Startup] Face encoding cache preloaded ?")
            except Exception as e:
                # DB migration run ??????? error ????? — safe-? ignore ????????
                print(f"[Startup] Cache preload skipped: {e}")

        # Background thread-?? load ??????? — server startup delay ????????
        t = threading.Thread(target=preload, daemon=True)
        t.start()