from gm_rpcd.all import bind

from libs.rpc import get_rpc_invoker
from hera.models.city_rank import CityWhiteList


@bind('doris/hera/in_city_whitelist')
def city_is_in_whitelist(city_ids):
    rs = []
    if not city_ids:
        return rs

    qs = CityWhiteList.objects.filter(city_id__in=city_ids).values_list('city_id', flat=True)
    return list(qs)


def in_city_white_list(city_tag_id):
    # rpc_invoker = get_rpc_invoker()
    # city = rpc_invoker['api/city/city_by_tag_id'](tag_id=city_tag_id).unwrap()
    # if city.get('city_id'):
    #     return CityWhiteList.objects.filter(city_id=city.get('city_id')).exists()
    return False