コード例 #1
0
def build_states_summary(state_data: List[APIOutput],
                         intervention) -> APIOutput:
    state_summaries = [
        output.data for output in state_data
        # Don't love using type here, but CovidActNowStateTimeseries inherits
        # CovidActNowStateSummary so `isinstance` returns true and fails to
        # filter out the timeseries records.
        if type(output.data) == CovidActNowStateSummary
    ]
    state_api_data = CovidActNowStatesSummary(data=state_summaries)
    key = f"states.{intervention.name}"
    return APIOutput(key, state_api_data)
コード例 #2
0
def build_states_summary(state_data: List[APIOutput],
                         intervention) -> APIOutput:
    data = [output.data for output in state_data]
    state_api_data = CovidActNowStatesSummary(__root__=data)
    key = f"states.{intervention.name}"
    return APIOutput(key, state_api_data, intervention)