Пример #1
0
def participatable_food_activity(restaurant_id):
    with thrift_client('ers') as ers:
        result = ers.get_participatable_food_activity_ids(restaurant_id)
        activity_ids = []
        result['8'] = set(result.values()[0]) if len(result) else set()
        for day in range(1, 8):
            result.setdefault(day, [])
            activity_ids.extend(result[day])
            result['8'] &= set(result[day])
        activities = food_act_base.mget(activity_ids)
        activity_map = {activity.id: activity for activity in activities}
        for day in range(1, 8):
            day_activity_ids = result[day]
            result[day] = [activity_map[_id] for _id in day_activity_ids]
        week_activity_ids = result['8']
        result['8'] = [activity_map[_id] for _id in week_activity_ids]
    return result
Пример #2
0
def participatable_food_activity(restaurant_id):
    with thrift_client('ers') as ers:
        result = ers.get_participatable_food_activity_ids(restaurant_id)
        activity_ids = []
        result['8'] = set(result.values()[0]) if len(result) else set()
        for day in range(1,8):
            result.setdefault(day,[])
            activity_ids.extend(result[day])
            result['8'] &= set(result[day])
        activities = food_act_base.mget(activity_ids)
        activity_map = {activity.id:activity for activity in activities}
        for day in range(1,8):
            day_activity_ids = result[day]
            result[day] = [activity_map[_id] for _id in day_activity_ids]
        week_activity_ids = result['8']
        result['8'] = [activity_map[_id] for _id in week_activity_ids]
    return result
Пример #3
0
def mget(activity_ids, category_id):
    ACTIVITY_CATEGORY = thirdparty_svc.ers.SubsidyConst()
    if category_id == ACTIVITY_CATEGORY.CATEGORY_RESTAURANT_ACTIVITY:
        return rst_activity.mget(activity_ids)
    elif category_id == ACTIVITY_CATEGORY.CATEGORY_FOOD_ACTIVITY:
        return food_activity.mget(activity_ids)