src/dirbs/reports/stats_generator.py
def _process_id_counts_future(per_operator_record_counts, statsd, metrics_run_root, monthly_stats, daily_stats,
                              debug_query_performance, f):
    """Function to process the result of the distinct ID counts future."""
    logger = logging.getLogger('dirbs.report')
    results, total_duration, component_durations = f.result()
    logger.info('Calculated distinct identifier counts for all operators (duration {0:.3f}s)'
                .format(total_duration / 1000))
    _print_component_query_perfomance(component_durations, debug_query_performance)
    # Future returns a row of dicts, so process each results
    for result in results:
        # If the operator_id is None, this row is a rollup to the country level
        operator_id = result.pop('operator_id')
        if operator_id is None:
            operator_id = OperatorConfig.COUNTRY_OPERATOR_NAME

        # If the data_date is none, this row is a rollup to the monthly level, otherwise date
        data_date = result.pop('data_date')
        if data_date is None:
            # At this point, all remaining non-popped values should be stored in the states
            monthly_stats[operator_id].update(result)
        else:
            dom = data_date.day
            daily_stats[operator_id][dom - 1].update(result)

    _log_perf_metric(statsd, metrics_run_root, 'identifier_counts', total_duration,
                     record_counts_map=per_operator_record_counts)
Function to process the result of the distinct ID counts future.
Function to process the result of the distinct ID counts future.
Function to process the result of the distinct ID counts future .
def _process_id_counts_future(per_operator_record_counts, statsd, metrics_run_root, monthly_stats, daily_stats,
                              debug_query_performance, f):
    logger = logging.getLogger('dirbs.report')
    results, total_duration, component_durations = f.result()
    logger.info('Calculated distinct identifier counts for all operators (duration {0:.3f}s)'
                .format(total_duration / 1000))
    _print_component_query_perfomance(component_durations, debug_query_performance)
    for result in results:
        operator_id = result.pop('operator_id')
        if operator_id is None:
            operator_id = OperatorConfig.COUNTRY_OPERATOR_NAME
        data_date = result.pop('data_date')
        if data_date is None:
            monthly_stats[operator_id].update(result)
        else:
            dom = data_date.day
            daily_stats[operator_id][dom - 1].update(result)
    _log_perf_metric(statsd, metrics_run_root, 'identifier_counts', total_duration,
                     record_counts_map=per_operator_record_counts)
def _process_id_counts_future ( per_operator_record_counts , statsd , metrics_run_root , monthly_stats , daily_stats , debug_query_performance , f ) : logger = logging . getLogger ( 'dirbs.report' ) results , total_duration , component_durations = f . result ( ) logger . info ( 'Calculated distinct identifier counts for all operators (duration {0:.3f}s)' . format ( total_duration / 1000 ) ) _print_component_query_perfomance ( component_durations , debug_query_performance ) for result in results : operator_id = result . pop ( 'operator_id' ) if operator_id is None : operator_id = OperatorConfig . COUNTRY_OPERATOR_NAME data_date = result . pop ( 'data_date' ) if data_date is None : monthly_stats [ operator_id ] . update ( result ) else : dom = data_date . day daily_stats [ operator_id ] [ dom - 1 ] . update ( result ) _log_perf_metric ( statsd , metrics_run_root , 'identifier_counts' , total_duration , record_counts_map = per_operator_record_counts )
Function to process the result of the distinct ID counts future.
Function to process the result of the distinct ID counts future .
"""Function to process the result of the distinct ID counts future.""" # Future returns a row of dicts, so process each results # If the operator_id is None, this row is a rollup to the country level # If the data_date is none, this row is a rollup to the monthly level, otherwise date # At this point, all remaining non-popped values should be stored in the states
per_operator_record_counts
statsd
metrics_run_root
monthly_stats
daily_stats
debug_query_performance
f