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

from __future__ import division

import json

from django_logit import logit
from django_response import response

from account.models import UserInfo
from utils.redis.connect import r
from utils.redis.rkeys import MEMBERCARD_USERINFO_LIST


@logit
def phone(request):
    users = UserInfo.objects.filter(phone='').exclude(memberusercardcode='').exclude(memberusercardcode__isnull=True)

    p = r.pipeline()
    for u in users:
        p.rpush(MEMBERCARD_USERINFO_LIST, json.dumps(u.cardata))
    p.execute()

    return response()
