output = "=================================================" output += "\r Summary of Calls Imported " output += "\r" output += "\rTotal Calls Parsed: %d" % ( parse_row_count -2 ) output += "\rTotal Calls Inserted: %d" % len( success_list ) #output += "\rTotal Calls Updated: %d" % update_count output += "\rTotal Calls Skipped: %d" % skip_count output += "\rCalls geocoded using Google: %d" % google_count output += "\rCalls geocoded using Yahoo: %d" % yahoo_count output += "\rCalls geocoded using Geocoder.us: %d" % geocoder_count output += "\r=================================================" if len( geocode_error_list ) > 0: output += "\rThese calls had errors on geocoding. ( Please look at and fix them!)" for error in geocode_error_list: output += "\r" + error output += "\r" output += "\r=================================================" if len( error_list ) > 0: output += "\rThese calls had errors saving to the database. ( Please look at and fix them!)" for error in error_list: output += "\r" + error output += "\r=================================================" print output email_message('Online Staff','*****@*****.**','911 Calls Importer','*****@*****.**','911 Calls Import: ' + today.strftime("%m-%d-%Y %I:%M %p"), output)
#get the featured stories first pvs = Pageview.objects.filter( time_init__range = ( datetime.datetime.today() - datetime.timedelta( days = 15 ), datetime.datetime.today() - datetime.timedelta( days = 13 ) ) ).exclude( story__featured = True ) pvs = pvs.values('story').annotate( pageviews = Count( 'id' ) ).order_by( '-pageviews' )[:15] for pv in pvs: pv[ 'story' ] = Story.objects.get( id = pv[ 'story' ] ) #for pv in pvs: # print pv #put in code for emailing here. start = datetime.datetime.today() - datetime.timedelta( days = 14 ) start = start.strftime( "%m-%d-%Y") message = "Here are the top 15 stories on %s. Please look and evergreen stories as needed.\r\n\r\n" % ( start ) count = 1 for pv in pvs: print repr( pv["story"] ) message += "%d: Story: %s\r\n Date Published: %s, Pageviews: %d \r\n URL: %s \r\n\r\n" % ( count, pv["story"].headline, pv["story"].date_published.strftime("%m-%d-%Y"), pv["pageviews"],pv["story"].short_url ) count += 1 print message email_message( "Online","*****@*****.**","Data Server","*****@*****.**", "Expiring Story Pageview Report", message )