Beispiel #1
0
def _set_region_to_rst(rst_dict):
    rst_to_region_map = region_base.get_region_map_by_rst(rst_dict.keys())
    region_ids = rst_to_region_map.values()
    region_to_region_group_map = \
        region_group_base.get_region_group_map_by_region(region_ids)
    for rst_id, rst in rst_dict.iteritems():
        if rst_to_region_map.get(rst_id) is not None:
            region_id = rst_to_region_map.get(rst_id)
            rst['region_id'] = region_id
            if region_to_region_group_map.get(region_id) is not None:
                rst['region_group_id'] = region_to_region_group_map.get(region_id)
            else:
                log.warning(u"region<{}>: could not find region_group.".format(region_id))
        else:
            log.warning(u"rst<{}>: could not find region.".format(rst_id))
def main():
    rsts = query_all_rsts(city_ids=[1], is_valid=1, is_premium=0)
    rst_region_map = region.get_region_map_by_rst([rst['id'] for rst in rsts])
    region_map = region.mget(list(set(rst_region_map.values())), return_map=True)
    unregioned_count = 0
    unregions = []

    for rst_id, region_id in rst_region_map.iteritems():
        if not region_map.has_key(region_id):
            unregioned_count += 1
            print('{}, {}'.format(rst_id, region_id))
            unregions.append(region_id)
            update_restaurant_region(rst_id, -10)

    print('total unregioned: {}'.format(unregioned_count))
    print('unregions: {}'.format(list(set(unregions))))
Beispiel #3
0
def main():
    rsts = query_all_rsts(city_ids=[1], is_valid=1, is_premium=0)
    rst_region_map = region.get_region_map_by_rst([rst['id'] for rst in rsts])
    region_map = region.mget(list(set(rst_region_map.values())),
                             return_map=True)
    unregioned_count = 0
    unregions = []

    for rst_id, region_id in rst_region_map.iteritems():
        if not region_map.has_key(region_id):
            unregioned_count += 1
            print('{}, {}'.format(rst_id, region_id))
            unregions.append(region_id)
            update_restaurant_region(rst_id, -10)

    print('total unregioned: {}'.format(unregioned_count))
    print('unregions: {}'.format(list(set(unregions))))
Beispiel #4
0
def _set_region_to_rst(rst_dict):
    rst_to_region_map = region_base.get_region_map_by_rst(rst_dict.keys())
    region_ids = rst_to_region_map.values()
    region_to_region_group_map = \
        region_group_base.get_region_group_map_by_region(region_ids)
    for rst_id, rst in rst_dict.iteritems():
        if rst_to_region_map.get(rst_id) is not None:
            region_id = rst_to_region_map.get(rst_id)
            rst['region_id'] = region_id
            if region_to_region_group_map.get(region_id) is not None:
                rst['region_group_id'] = region_to_region_group_map.get(
                    region_id)
            else:
                log.warning(u"region<{}>: could not find region_group.".format(
                    region_id))
        else:
            log.warning(u"rst<{}>: could not find region.".format(rst_id))