def get_promo_traffic(thing, start, end):
 if isinstance(thing, Link):
  imp_fn = traffic.AdImpressionsByCodename.promotion_history
  click_fn = traffic.ClickthroughsByCodename.promotion_history
 elif isinstance(thing, PromoCampaign):
  imp_fn = traffic.TargetedImpressionsByCodename.promotion_history
  click_fn = traffic.TargetedClickthroughsByCodename.promotion_history
 imps = imp_fn(thing._fullname, start.replace(tzinfo=None), end.replace(tzinfo=None))
 clicks = click_fn(thing._fullname, start.replace(tzinfo=None), end.replace(tzinfo=None))
 if (imps and (not clicks)):
  clicks = [(imps[0][0], (0,))]
 elif (clicks and (not imps)):
  imps = [(clicks[0][0], (0,))]
 history = traffic.zip_timeseries(imps, clicks, order='ascending')
 return history

def get_promo_traffic ( thing , start , end ) : if isinstance ( thing , Link ) : imp_fn = traffic . AdImpressionsByCodename . promotion_history click_fn = traffic . ClickthroughsByCodename . promotion_history elif isinstance ( thing , PromoCampaign ) : imp_fn = traffic . TargetedImpressionsByCodename . promotion_history click_fn = traffic . TargetedClickthroughsByCodename . promotion_history imps = imp_fn ( thing . _fullname , start . replace ( tzinfo = None ) , end . replace ( tzinfo = None ) ) clicks = click_fn ( thing . _fullname , start . replace ( tzinfo = None ) , end . replace ( tzinfo = None ) ) if ( imps and ( not clicks ) ) : clicks = [ ( imps [ 0 ] [ 0 ] , ( 0 , ) ) ] elif ( clicks and ( not imps ) ) : imps = [ ( clicks [ 0 ] [ 0 ] , ( 0 , ) ) ] history = traffic . zip_timeseries ( imps , clicks , order = 'ascending' ) return history
get traffic for a promoted link or promocampaign .