예제 #1
0
파일: tasks.py 프로젝트: wpride/commcare-hq
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)
예제 #2
0
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)