from django.contrib.auth.models import User
from django.core.management import BaseCommand

from api.models import UserExtra
from social.models import UserFollow


class Command(BaseCommand):
    def handle(self, *args, **options):
        follows = UserFollow.objects.filter(is_virtual_fan=True)
        for follow in follows:
            user = User.objects.filter(id=follow.user_id).first()
            if user:
                continue
            else:
                print(follow.id)
                user_extra = UserExtra.objects.filter(id=follow.user_id).first()
                if user_extra:
                    follow.user_id = user_extra.user_id
                    follow.save()
