def handle(self, domain, **options):
        csv = options.get('csv')

        couch_counts = map_counter_doc_types(_get_couchdb_counts(domain))
        sql_counts = map_counter_doc_types(_get_sql_counts(domain))
        es_counts = map_counter_doc_types(get_es_counts_by_doc_type(domain))
        all_doc_types = set(couch_counts) | set(sql_counts) | set(es_counts)

        output_rows = []
        for doc_type in sorted(all_doc_types, key=lambda d: d.lower()):
            couch = couch_counts.get(doc_type, '')
            sql = sql_counts.get(doc_type, '')
            es = es_counts.get(doc_type, '')
            output_rows.append((doc_type, couch, sql, es))

        if csv:
            row_formatter = CSVRowFormatter()
        else:
            row_formatter = TableRowFormatter(
                [50, 20, 20, 20],
                _get_row_color
            )

        SimpleTableWriter(self.stdout, row_formatter).write_table(
            ['Doc Type', 'Couch', 'SQL', 'ES'], output_rows
        )
Example #2
0
    def handle(self, domain, **options):
        csv = options.get('csv')

        couch_counts = map_counter_doc_types(_get_couchdb_counts(domain))
        sql_counts = map_counter_doc_types(_get_sql_counts(domain))
        es_counts = map_counter_doc_types(get_es_counts_by_doc_type(domain))
        all_doc_types = set(couch_counts) | set(sql_counts) | set(es_counts)

        output_rows = []
        for doc_type in sorted(all_doc_types, key=lambda d: d.lower()):
            couch = couch_counts.get(doc_type, '')
            sql = sql_counts.get(doc_type, '')
            es = es_counts.get(doc_type, '')
            output_rows.append((doc_type, couch, sql, es))

        if csv:
            row_formatter = CSVRowFormatter()
        else:
            row_formatter = TableRowFormatter(
                [50, 20, 20, 20],
                _get_row_color
            )

        SimpleTableWriter(self.stdout, row_formatter).write_table(
            ['Doc Type', 'Couch', 'SQL', 'ES'], output_rows
        )
Example #3
0
def get_doc_counts_for_domain(domain):
    """
    :param domain:
    :return: List of tuples: ``(doc_type, primary_db_count, es_count)``
    """
    primary_db_counts = map_counter_doc_types(_get_primary_db_counts(domain))
    es_counts = map_counter_doc_types(
        get_es_counts_by_doc_type(domain, (es.CaseES, es.FormES)))
    es_counts.update(get_es_user_counts_by_doc_type(domain))

    all_doc_types = set(primary_db_counts) | set(es_counts)

    output_rows = []
    for doc_type in sorted(all_doc_types, key=lambda d: d.lower()):
        output_rows.append(
            (doc_type, primary_db_counts[doc_type], es_counts[doc_type]))

    return output_rows
Example #4
0
def get_doc_counts_for_domain(domain):
    """
    :param domain:
    :return: List of tuples: ``(doc_type, primary_db_count, es_count)``
    """
    primary_db_counts = map_counter_doc_types(_get_primary_db_counts(domain))
    es_counts = map_counter_doc_types(
        get_es_counts_by_doc_type(domain, (es.CaseES, es.FormES))
    )
    es_counts.update(get_es_user_counts_by_doc_type(domain))

    all_doc_types = set(primary_db_counts) | set(es_counts)

    output_rows = []
    for doc_type in sorted(all_doc_types, key=lambda d: d.lower()):
        output_rows.append((
            doc_type,
            primary_db_counts[doc_type],
            es_counts[doc_type]
        ))

    return output_rows