#NEWLINE# def generate_fixtures_for_domain( domain , db , data_source ) : #NEWLINE# #INDENT# location_ids = [ location . get_id for location in Location . by_domain ( domain ) ] #NEWLINE# dates = get_last_n_months ( NUMBER_OF_MONTHS_FOR_FIXTURES ) #NEWLINE# for date in dates : #NEWLINE# #INDENT# for location_id in location_ids : #NEWLINE# #INDENT# data_source . configure ( config = { #NEWLINE# #INDENT# 'startdate' : date [ 0 ] , #NEWLINE# 'enddate' : date [ 1 ] , #NEWLINE# 'location_id' : location_id , #NEWLINE# 'domain' : domain , #NEWLINE# #UNINDENT# } ) #NEWLINE# report_data = data_source . get_data ( ) #NEWLINE# for report_slug in report_data : #NEWLINE# #INDENT# rows = dict ( report_data [ report_slug ] . get ( 'data' , [ ] ) ) #NEWLINE# name = report_data [ report_slug ] . get ( 'name' ) #NEWLINE# db . delete_docs ( FixtureReportResult . all_by_composite_key ( domain , location_id , json_format_date ( date [ 0 ] ) , json_format_date ( date [ 1 ] ) , report_slug ) ) #NEWLINE# FixtureReportResult . save_result ( domain , location_id , date [ 0 ] . date ( ) , date [ 1 ] . date ( ) , report_slug , rows , name )