Example #1
0
def get_indicator_adapter(config, raise_errors=False, load_source="unknown"):
    from corehq.apps.userreports.sql.adapter import IndicatorSqlAdapter, ErrorRaisingIndicatorSqlAdapter
    if raise_errors:
        adapter = ErrorRaisingIndicatorSqlAdapter(config)
    else:
        adapter = IndicatorSqlAdapter(config)

    track_load = ucr_load_counter(config.engine_id, load_source, config.domain)
    return IndicatorAdapterLoadTracker(adapter, track_load)
Example #2
0
def get_indicator_adapter(config, raise_errors=False, load_source="unknown"):
    from corehq.apps.userreports.sql.adapter import IndicatorSqlAdapter, ErrorRaisingIndicatorSqlAdapter, \
        MultiDBSqlAdapter, ErrorRaisingMultiDBAdapter
    requires_mirroring = config.mirrored_engine_ids
    if requires_mirroring and ENABLE_UCR_MIRRORS.enabled(config.domain):
        adapter_cls = ErrorRaisingMultiDBAdapter if raise_errors else MultiDBSqlAdapter
    else:
        adapter_cls = ErrorRaisingIndicatorSqlAdapter if raise_errors else IndicatorSqlAdapter
    adapter = adapter_cls(config)
    track_load = ucr_load_counter(config.engine_id, load_source, config.domain)
    return IndicatorAdapterLoadTracker(adapter, track_load)