def generate_fixtures_for_domain(domain, db, data_source): # Remove all FixtureReportResult instances, as they would either be deleted or replaced anyway db.delete_docs(FixtureReportResult.by_domain(domain=domain)) location_ids = [location.get_id for location in Location.by_domain(domain)] dates = get_last_n_months(NUMBER_OF_MONTHS_FOR_FIXTURES) for date in dates: for location_id in location_ids: data_source.configure(config={ "startdate": date[0], "enddate": date[1], "location_id": location_id, "domain": domain }) report_data = data_source.get_data() for report_slug in report_data: rows = dict(report_data[report_slug].get("data", [])) name = report_data[report_slug].get("name") FixtureReportResult.save_result(domain, location_id, date[0].date(), date[1].date(), report_slug, rows, name)
def generate_fixtures_for_domain(domain, db, data_source): # Remove all FixtureReportResult instances, as they would either be deleted or replaced anyway db.delete_docs(FixtureReportResult.by_domain(domain=domain)) location_ids = [location.get_id for location in Location.by_domain(domain)] dates = get_last_n_months(NUMBER_OF_MONTHS_FOR_FIXTURES) for date in dates: for location_id in location_ids: data_source.configure(config={ "startdate": date[0], "enddate": date[1], "location_id": location_id, "domain": domain }) report_data = data_source.get_data() for report_slug in report_data: rows = dict(report_data[report_slug].get("data", [])) name = report_data[report_slug].get("name") FixtureReportResult.save_result(domain, location_id, date[0].date(), date[1].date(), report_slug, rows, name)