# -*- coding: utf-8 -*-

from django.apps import apps
from django.core.management.base import BaseCommand


class Command(BaseCommand):
    args = ''
    help = 'Show the count of every object in database.'

    def handle(self, *args, **options):
        for app_config in apps.get_app_configs():
            if not app_config.models_module or not app_config.models:
                continue
            if app_config.models_module.__name__ == "mtp.apps.formation.models" or \
                    app_config.models_module.__name__ == "mtp.apps.sync.models":
                for model in app_config.models.values():
                    count = model.objects.all().count()
                    print("%s: %d" % (model.__name__, count))
