def get_predicted_pageviews(srs, location=None):
 (srs, is_single) = tup(srs, ret_is_single=True)
 sr_names = [sr.name for sr in srs]
 default_srids = LocalizedDefaultSubreddits.get_global_defaults()
 if location:
  no_location = Location(None)
  r = LocationPromoMetrics.get(DefaultSR, [no_location, location])
  location_pageviews = r[(DefaultSR, location)]
  all_pageviews = r[(DefaultSR, no_location)]
  if all_pageviews:
   location_factor = (float(location_pageviews) / float(all_pageviews))
  else:
   location_factor = 0.0
 else:
  location_factor = 1.0
 daily_inventory = PromoMetrics.get(MIN_DAILY_CASS_KEY, sr_names=sr_names)
 ret = {}
 for sr in srs:
  if ((not isinstance(sr, FakeSubreddit)) and (sr._id in default_srids)):
   default_factor = DEFAULT_INVENTORY_FACTOR
  else:
   default_factor = INVENTORY_FACTOR
  base_pageviews = daily_inventory.get(sr.name, 0)
  ret[sr.name] = int(((base_pageviews * default_factor) * location_factor))
 if is_single:
  return ret[srs[0].name]
 else:
  return ret

def get_predicted_pageviews ( srs , location = None ) : ( srs , is_single ) = tup ( srs , ret_is_single = True ) sr_names = [ sr . name for sr in srs ] default_srids = LocalizedDefaultSubreddits . get_global_defaults ( ) if location : no_location = Location ( None ) r = LocationPromoMetrics . get ( DefaultSR , [ no_location , location ] ) location_pageviews = r [ ( DefaultSR , location ) ] all_pageviews = r [ ( DefaultSR , no_location ) ] if all_pageviews : location_factor = ( float ( location_pageviews ) / float ( all_pageviews ) ) else : location_factor = 0.0 else : location_factor = 1.0 daily_inventory = PromoMetrics . get ( MIN_DAILY_CASS_KEY , sr_names = sr_names ) ret = { } for sr in srs : if ( ( not isinstance ( sr , FakeSubreddit ) ) and ( sr . _id in default_srids ) ) : default_factor = DEFAULT_INVENTORY_FACTOR else : default_factor = INVENTORY_FACTOR base_pageviews = daily_inventory . get ( sr . name , 0 ) ret [ sr . name ] = int ( ( ( base_pageviews * default_factor ) * location_factor ) ) if is_single : return ret [ srs [ 0 ] . name ] else : return ret
return predicted number of pageviews for sponsored headlines .