src/dirbs/reports/stats_generator.py
def _calc_invalid_id_null_counts(db_config, month, year):
    """Calculate per-operator monthly stats about invalid data (null) for a given month and year."""
    with utils.create_db_connection(db_config) as conn, conn.cursor() as cursor, utils.CodeProfiler() as cp:
        results = defaultdict(lambda: dict(num_null_imei_records=0,
                                           num_null_imsi_records=0,
                                           num_null_msisdn_records=0))
        durations = []
        for column, result_label in [('imei_norm', 'num_null_imei_records'),
                                     ('imsi', 'num_null_imsi_records'),
                                     ('msisdn', 'num_null_msisdn_records')]:
            with utils.CodeProfiler() as scp:
                # Calculate per-operator NULL counts
                cursor.execute(sql.SQL("""SELECT operator_id,
                                                 COUNT(*) AS cnt
                                            FROM monthly_network_triplets_per_mno
                                           WHERE triplet_month = %s
                                             AND triplet_year = %s
                                             AND {0} IS NULL
                                        GROUP BY operator_id""").format(sql.Identifier(column)),
                               [month, year])
                for res in cursor:
                    results[res.operator_id][result_label] = res.cnt
            durations.append(scp.duration)

            with utils.CodeProfiler() as scp:
                # Calculate per-country NULL counts
                cursor.execute(sql.SQL("""SELECT COUNT(*) AS cnt
                                            FROM monthly_network_triplets_country
                                           WHERE triplet_month = %s
                                             AND triplet_year = %s
                                             AND {0} IS NULL""").format(sql.Identifier(column)),
                               [month, year])
                for res in cursor:
                    results[OperatorConfig.COUNTRY_OPERATOR_NAME][result_label] = res.cnt
            durations.append(scp.duration)

    return _defaultdict_to_regular(results), cp.duration, durations
Calculate per-operator monthly stats about invalid data (null) for a given month and year.
Calculate per-operator monthly stats about invalid data (null) for a given month and year.
Calculate per - operator monthly stats about invalid data ( null ) for a given month and year .
def _calc_invalid_id_null_counts(db_config, month, year):
    with utils.create_db_connection(db_config) as conn, conn.cursor() as cursor, utils.CodeProfiler() as cp:
        results = defaultdict(lambda: dict(num_null_imei_records=0,
                                           num_null_imsi_records=0,
                                           num_null_msisdn_records=0))
        durations = []
        for column, result_label in [('imei_norm', 'num_null_imei_records'),
                                     ('imsi', 'num_null_imsi_records'),
                                     ('msisdn', 'num_null_msisdn_records')]:
            with utils.CodeProfiler() as scp:
                cursor.execute(sql.SQL("""SELECT operator_id,
                                                 COUNT(*) AS cnt
                                            FROM monthly_network_triplets_per_mno
                                           WHERE triplet_month = %s
                                             AND triplet_year = %s
                                             AND {0} IS NULL
                                        GROUP BY operator_id""").format(sql.Identifier(column)),
                               [month, year])
                for res in cursor:
                    results[res.operator_id][result_label] = res.cnt
            durations.append(scp.duration)
            with utils.CodeProfiler() as scp:
                cursor.execute(sql.SQL("""SELECT COUNT(*) AS cnt
                                            FROM monthly_network_triplets_country
                                           WHERE triplet_month = %s
                                             AND triplet_year = %s
                                             AND {0} IS NULL""").format(sql.Identifier(column)),
                               [month, year])
                for res in cursor:
                    results[OperatorConfig.COUNTRY_OPERATOR_NAME][result_label] = res.cnt
            durations.append(scp.duration)
    return _defaultdict_to_regular(results), cp.duration, durations
def _calc_invalid_id_null_counts ( db_config , month , year ) : with utils . create_db_connection ( db_config ) as conn , conn . cursor ( ) as cursor , utils . CodeProfiler ( ) as cp : results = defaultdict ( lambda : dict ( num_null_imei_records = 0 , num_null_imsi_records = 0 , num_null_msisdn_records = 0 ) ) durations = [ ] for column , result_label in [ ( 'imei_norm' , 'num_null_imei_records' ) , ( 'imsi' , 'num_null_imsi_records' ) , ( 'msisdn' , 'num_null_msisdn_records' ) ] : with utils . CodeProfiler ( ) as scp : cursor . execute ( sql . SQL ( """SELECT operator_id,
                                                 COUNT(*) AS cnt
                                            FROM monthly_network_triplets_per_mno
                                           WHERE triplet_month = %s
                                             AND triplet_year = %s
                                             AND {0} IS NULL
                                        GROUP BY operator_id""" ) . format ( sql . Identifier ( column ) ) , [ month , year ] ) for res in cursor : results [ res . operator_id ] [ result_label ] = res . cnt durations . append ( scp . duration ) with utils . CodeProfiler ( ) as scp : cursor . execute ( sql . SQL ( """SELECT COUNT(*) AS cnt
                                            FROM monthly_network_triplets_country
                                           WHERE triplet_month = %s
                                             AND triplet_year = %s
                                             AND {0} IS NULL""" ) . format ( sql . Identifier ( column ) ) , [ month , year ] ) for res in cursor : results [ OperatorConfig . COUNTRY_OPERATOR_NAME ] [ result_label ] = res . cnt durations . append ( scp . duration ) return _defaultdict_to_regular ( results ) , cp . duration , durations
Calculate per-operator monthly stats about invalid data (null) for a given month and year.
Calculate per - operator monthly stats about invalid data ( null ) for a given month and year .
"""Calculate per-operator monthly stats about invalid data (null) for a given month and year.""" # Calculate per-operator NULL counts # Calculate per-country NULL counts
db_config
month
year