# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.core.management import BaseCommand

from api.models.user import UserExtra


class Command(BaseCommand):

    def handle(self, *args, **options):
        user_ids = UserExtra.objects.filter(phone__isnull=False).values('user_id')
        with open('/tmp/has_phone_user_ids.txt', 'wb') as f:
            for user_id in user_ids:
                f.write(str(user_id['user_id']))
                f.write('\n')

        print 'last one is : {}'.format(user_ids.last())
        print '-----------Done!-----------'
