Example #1
0
 def rebuild_tables_if_necessary(self):
     sql_supported_backends = [UCR_SQL_BACKEND, UCR_LABORATORY_BACKEND]
     es_supported_backends = [UCR_ES_BACKEND, UCR_LABORATORY_BACKEND]
     self._rebuild_sql_tables(
         filter(lambda a: get_backend_id(a.config) in sql_supported_backends, self.table_adapters))
     self._rebuild_es_tables(
         filter(lambda a: get_backend_id(a.config) in es_supported_backends, self.table_adapters))
 def override_backend_id(self, new_backend):
     assert get_backend_id(
         self.config,
         can_handle_laboratory=True) in (UCR_LABORATORY_BACKEND,
                                         UCR_ES_PRIMARY)
     assert new_backend == UCR_ES_BACKEND or new_backend == UCR_SQL_BACKEND
     self._backend = new_backend
     self.config.backend_id = new_backend
Example #3
0
 def data_source(self):
     if self._data_source is None:
         if get_backend_id(self.config) == 'SQL':
             self._data_source = ConfigurableReportSqlDataSource(
                 self.domain, self.config, self._filters,
                 self._aggregation_columns, self._columns, self._order_by)
         else:
             self._data_source = ConfigurableReportEsDataSource(
                 self.domain, self.config, self._filters,
                 self._aggregation_columns, self._columns, self._order_by)
     return self._data_source
Example #4
0
def _get_expanded_column(data_source_config, report_column, values, lang):
    """
    Given an ExpandedColumn, return a list of Column-like objects. Each column
    is configured to show the number of occurrences of one of the given distinct_values.

    :param report_column:
    :param distinct_values:
    :return:
    """
    from corehq.apps.userreports.sql.columns import expand_column as sql_expand_column
    from corehq.apps.userreports.es.columns import expand_column as es_expand_column
    backend_id = get_backend_id(data_source_config)
    if backend_id == UCR_ES_BACKEND:
        fn = es_expand_column
    else:
        fn = sql_expand_column
    return fn(report_column, values, lang)
Example #5
0
 def backend(self):
     if self._backend is None:
         self._backend = get_backend_id(self.config)
     return self._backend
Example #6
0
 def override_backend_id(self, new_backend):
     assert get_backend_id(self.config, can_handle_laboratory=True) == UCR_LABORATORY_BACKEND
     assert new_backend == UCR_ES_BACKEND or new_backend == UCR_SQL_BACKEND
     self._backend = new_backend
     self.config.backend_id = new_backend
Example #7
0
 def _tables_by_engine_id(self, engine_ids):
     return [
         adapter for adapter_list in self.table_adapters_by_domain.values()
         for adapter in adapter_list
         if get_backend_id(adapter.config) in engine_ids
     ]