Beispiel #1
0
def _create_banner(b_type, args):
    if b_type == banner_type.NON_INTERACTIVE:
        return dict2ttype(args, NonInteractiveBanner(),
                          NON_INTERACTIVE_BANNER_ATTRIBUTES)

    if b_type == banner_type.LINK:
        return dict2ttype(args, LinkBanner(), LINK_BANNER_ATTRIBUTES)

    if b_type == banner_type.ACTIVITY:
        return dict2ttype(args, ActivityBanner(), ACTIVITY_BANNER_ATTRIBUTES)
Beispiel #2
0
def _create_banner(b_type, args):
    if b_type == banner_type.NON_INTERACTIVE:
        return dict2ttype(args,
                          NonInteractiveBanner(),
                          NON_INTERACTIVE_BANNER_ATTRIBUTES)

    if b_type == banner_type.LINK:
        return dict2ttype(args,
                          LinkBanner(),
                          LINK_BANNER_ATTRIBUTES)

    if b_type == banner_type.ACTIVITY:
        return dict2ttype(args,
                          ActivityBanner(),
                          ACTIVITY_BANNER_ATTRIBUTES)
Beispiel #3
0
def query(args):
    query_struct = dict2ttype(args, BannerQuery())
    query_struct.order_by = [
        '-created_at',
    ]
    with thrift_client('keeper') as keeper:
        results = keeper.javis_query_banners(query_struct)
    return results.banners, results.count
Beispiel #4
0
def create_act_stats_query(args):
    page_no, page_size = get_paging_params()
    t_query = dict2ttype(args, thirdparty_svc.eos.TActivityStatsQuery(),
                         keys=['activity_id', 'activity_category_id',
                               'from_date', 'to_date'])
    if t_query.activity_id:
        t_query.activity_id = int(t_query.activity_id)
    if t_query.activity_category_id:
        t_query.activity_category_id = int(t_query.activity_category_id)
    t_query.offset = (page_no - 1) * page_size
    t_query.limit = page_size

    status = args.get('status')
    city_id = args.get('city_id')
    restaurant_id = args.get('restaurant_id')

    city_ids, rest_ids = get_city_ids_or_restaurant_ids_by_user()
    t_query.city_ids = city_ids
    t_query.restaurant_ids = rest_ids

    if status:
        t_query.statuses = [int(status), ]

    if city_id:
        city_id = int(city_id)
        if city_ids is None or city_id in city_ids:
            t_query.city_ids = [city_id, ]
        else:
            return None

    if restaurant_id:
        restaurant_id = int(restaurant_id)
        if rest_ids is None or restaurant_id in rest_ids:
            t_query.restaurant_ids = [restaurant_id, ]
        else:
            return None
    return t_query
Beispiel #5
0
def query(args):
    query_struct = dict2ttype(args, BannerQuery())
    query_struct.order_by = ['-created_at', ]
    with thrift_client('keeper') as keeper:
        results = keeper.javis_query_banners(query_struct)
    return results.banners, results.count