当前位置: 首页>>代码示例>>Python>>正文


Python StaticDataSourceConfiguration.get_doc_id方法代码示例

本文整理汇总了Python中corehq.apps.userreports.models.StaticDataSourceConfiguration.get_doc_id方法的典型用法代码示例。如果您正苦于以下问题:Python StaticDataSourceConfiguration.get_doc_id方法的具体用法?Python StaticDataSourceConfiguration.get_doc_id怎么用?Python StaticDataSourceConfiguration.get_doc_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在corehq.apps.userreports.models.StaticDataSourceConfiguration的用法示例。


在下文中一共展示了StaticDataSourceConfiguration.get_doc_id方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: handle

# 需要导入模块: from corehq.apps.userreports.models import StaticDataSourceConfiguration [as 别名]
# 或者: from corehq.apps.userreports.models.StaticDataSourceConfiguration import get_doc_id [as 别名]
    def handle(self, file_path, *args, **options):
        domain = 'icds-cas'

        data_source_id = StaticDataSourceConfiguration.get_doc_id(domain, PERSON_TABLE_ID)
        config = StaticDataSourceConfiguration.by_id(data_source_id)
        adapter = get_indicator_adapter(config)
        session_helper = connection_manager.get_session_helper(adapter.engine_id)
        person_table_name = get_table_name(domain, PERSON_TABLE_ID)
        awc_location_table_name = get_table_name(domain, AWC_LOCATION_TABLE_ID)
        session = session_helper.Session

        with open(
            os.path.join(os.path.dirname(__file__), 'sql_scripts', 'nos_of_deaths.sql'),
            encoding='utf-8'
        ) as f:
            sql_script = f.read()
            rows = session.execute(
                sql_script % {
                    'person_table_name': person_table_name,
                    'awc_location_table_name': awc_location_table_name
                }
            )

            with open(file_path, 'w', encoding='utf-8') as file_object:
                writer = csv.writer(file_object)
                writer.writerow([
                    'State',
                    'District',
                    'AWC',
                    'Month',
                    'Deaths',
                ])
                writer.writerows(rows)
开发者ID:kkrampa,项目名称:commcare-hq,代码行数:35,代码来源:nos_of_deaths.py

示例2: handle

# 需要导入模块: from corehq.apps.userreports.models import StaticDataSourceConfiguration [as 别名]
# 或者: from corehq.apps.userreports.models.StaticDataSourceConfiguration import get_doc_id [as 别名]
    def handle(self, domains, **options):
        if not domains and not options['all']:
            raise CommandError('Specify specific domains or --all')

        all_domains = [domain.name for domain in get_call_center_domains() if domain.use_fixtures]
        if domains:
            for domain in domains:
                assert domain in all_domains, "Domain '{}' is not a Call Center domain".format(domain)
        else:
            domains = all_domains

        threshold = options['threshold']
        domain_stats = get_call_center_data_source_stats(domains)
        for domain in domains:
            stats = domain_stats[domain]
            print('Checking domain:', domain)
            if stats.error:
                print('Error getting stats:\n', stats.error)
                continue

            for stat in stats.iter_data_source_stats():
                diff = math.fabs(stat.ucr_percent - stat.es_percent)
                if diff > threshold:
                    print("rebuilding data source '{}' in domain '{}': diff = {}".format(
                        stat.name, domain, diff
                    ))
                    try:
                        rebuild_indicators(
                            StaticDataSourceConfiguration.get_doc_id(domain, TABLE_IDS[stat.name])
                        )
                    except Exception as e:
                        sys.stderr.write("Error rebuilding data source '{}' in domain '{}':\n{}".format(
                            stat.name, domain, e
                        ))
开发者ID:kkrampa,项目名称:commcare-hq,代码行数:36,代码来源:rebuild_call_center_datasources.py

示例3: _make_data_source_for_domain

# 需要导入模块: from corehq.apps.userreports.models import StaticDataSourceConfiguration [as 别名]
# 或者: from corehq.apps.userreports.models.StaticDataSourceConfiguration import get_doc_id [as 别名]
def _make_data_source_for_domain(data_source_json, domain_name):
    from corehq.apps.userreports.models import StaticDataSourceConfiguration
    from corehq.apps.userreports.models import DataSourceConfiguration

    doc = deepcopy(data_source_json)
    doc['domain'] = domain_name
    doc['_id'] = StaticDataSourceConfiguration.get_doc_id(domain_name, doc['table_id'])
    return DataSourceConfiguration.wrap(doc)
开发者ID:saketkanth,项目名称:commcare-hq,代码行数:10,代码来源:data_source.py

示例4: copy_ucr_datasources

# 需要导入模块: from corehq.apps.userreports.models import StaticDataSourceConfiguration [as 别名]
# 或者: from corehq.apps.userreports.models.StaticDataSourceConfiguration import get_doc_id [as 别名]
    def copy_ucr_datasources(self):
        datasource_map = {}
        datasources = get_datasources_for_domain(self.existing_domain)
        for datasource in datasources:
            datasource.meta.build.finished = False
            datasource.meta.build.initiated = None

            old_id, new_id = self.save_couch_copy(datasource, self.new_domain)
            datasource_map[old_id] = new_id
        for static_datasource in StaticDataSourceConfiguration.by_domain(self.existing_domain):
            table_id = static_datasource.get_id.replace(
                StaticDataSourceConfiguration._datasource_id_prefix + self.existing_domain + "-", ""
            )
            new_id = StaticDataSourceConfiguration.get_doc_id(self.new_domain, table_id)
            # check that new datasource is in new domain's list of static datasources
            StaticDataSourceConfiguration.by_id(new_id)
            datasource_map[static_datasource.get_id] = new_id
        return datasource_map
开发者ID:dimagi,项目名称:commcare-hq,代码行数:20,代码来源:clone_domain.py

示例5: ccs_record_monthly_ucr_tablename

# 需要导入模块: from corehq.apps.userreports.models import StaticDataSourceConfiguration [as 别名]
# 或者: from corehq.apps.userreports.models.StaticDataSourceConfiguration import get_doc_id [as 别名]
 def ccs_record_monthly_ucr_tablename(self):
     doc_id = StaticDataSourceConfiguration.get_doc_id(self.domain, 'static-ccs_record_cases_monthly_tableau_v2')
     config, _ = get_datasource_config(doc_id, self.domain)
     return get_table_name(self.domain, config.table_id)
开发者ID:kkrampa,项目名称:commcare-hq,代码行数:6,代码来源:mbt.py

示例6: _old_ucr_tablename

# 需要导入模块: from corehq.apps.userreports.models import StaticDataSourceConfiguration [as 别名]
# 或者: from corehq.apps.userreports.models.StaticDataSourceConfiguration import get_doc_id [as 别名]
 def _old_ucr_tablename(self):
     doc_id = StaticDataSourceConfiguration.get_doc_id(self.domain, self.ccs_record_monthly_ucr_id)
     config, _ = get_datasource_config(doc_id, self.domain)
     return get_table_name(self.domain, config.table_id)
开发者ID:kkrampa,项目名称:commcare-hq,代码行数:6,代码来源:postnatal_care_forms_ccs_record.py

示例7: get_asha_table_name

# 需要导入模块: from corehq.apps.userreports.models import StaticDataSourceConfiguration [as 别名]
# 或者: from corehq.apps.userreports.models.StaticDataSourceConfiguration import get_doc_id [as 别名]
 def get_asha_table_name(self):
     config = StaticDataSourceConfiguration.by_id(
         StaticDataSourceConfiguration.get_doc_id(DOMAIN, TABLE_ID)
     )
     return get_table_name(config.domain, config.table_id)
开发者ID:kkrampa,项目名称:commcare-hq,代码行数:7,代码来源:sql_data.py

示例8: get_asha_table

# 需要导入模块: from corehq.apps.userreports.models import StaticDataSourceConfiguration [as 别名]
# 或者: from corehq.apps.userreports.models.StaticDataSourceConfiguration import get_doc_id [as 别名]
 def get_asha_table(self, metadata):
     config = StaticDataSourceConfiguration.by_id(
         StaticDataSourceConfiguration.get_doc_id(DOMAIN, TABLE_ID)
     )
     return get_indicator_table(config, custom_metadata=metadata)
开发者ID:tlwakwella,项目名称:commcare-hq,代码行数:7,代码来源:sql_data.py

示例9: child_health_case_ucr_tablename

# 需要导入模块: from corehq.apps.userreports.models import StaticDataSourceConfiguration [as 别名]
# 或者: from corehq.apps.userreports.models.StaticDataSourceConfiguration import get_doc_id [as 别名]
 def child_health_case_ucr_tablename(self):
     doc_id = StaticDataSourceConfiguration.get_doc_id(self.domain, 'static-child_health_cases')
     config, _ = get_datasource_config(doc_id, self.domain)
     return get_table_name(self.domain, config.table_id)
开发者ID:kkrampa,项目名称:commcare-hq,代码行数:6,代码来源:child_health_monthly.py


注:本文中的corehq.apps.userreports.models.StaticDataSourceConfiguration.get_doc_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。