src/dirbs/reports/stats_generator.py
def _calc_top_models_gross_adds(db_config, month, year, operator=None):
    """Helper function to calculate the top models by gross adds."""
    with utils.create_db_connection(db_config) as conn:
        start_date, end_date = _calc_date_range(month, year)
        network_triplets_partition = _monthly_network_triplets_partition(conn=conn, operator=operator,
                                                                         month=month, year=year)
        return _calc_top_models_common(
            conn,
            sql.SQL("""SELECT SUBSTRING(imei_norm, 1, 8) AS tac,
                              COUNT(imei_norm) AS imei_count
                         FROM network_imeis
                        WHERE network_imeis.first_seen >= %s
                          AND network_imeis.first_seen < %s
                          AND EXISTS (SELECT 1
                                        FROM {0}
                                       WHERE imei_norm = network_imeis.imei_norm)
                     GROUP BY tac
                    """).format(network_triplets_partition),
            [start_date, end_date]
        )
Helper function to calculate the top models by gross adds.
Helper function to calculate the top models by gross adds.
Helper function to calculate the top models by gross adds .
def _calc_top_models_gross_adds(db_config, month, year, operator=None):
    with utils.create_db_connection(db_config) as conn:
        start_date, end_date = _calc_date_range(month, year)
        network_triplets_partition = _monthly_network_triplets_partition(conn=conn, operator=operator,
                                                                         month=month, year=year)
        return _calc_top_models_common(
            conn,
            sql.SQL("""SELECT SUBSTRING(imei_norm, 1, 8) AS tac,
                              COUNT(imei_norm) AS imei_count
                         FROM network_imeis
                        WHERE network_imeis.first_seen >= %s
                          AND network_imeis.first_seen < %s
                          AND EXISTS (SELECT 1
                                        FROM {0}
                                       WHERE imei_norm = network_imeis.imei_norm)
                     GROUP BY tac
                    """).format(network_triplets_partition),
            [start_date, end_date]
        )
def _calc_top_models_gross_adds ( db_config , month , year , operator = None ) : with utils . create_db_connection ( db_config ) as conn : start_date , end_date = _calc_date_range ( month , year ) network_triplets_partition = _monthly_network_triplets_partition ( conn = conn , operator = operator , month = month , year = year ) return _calc_top_models_common ( conn , sql . SQL ( """SELECT SUBSTRING(imei_norm, 1, 8) AS tac,
                              COUNT(imei_norm) AS imei_count
                         FROM network_imeis
                        WHERE network_imeis.first_seen >= %s
                          AND network_imeis.first_seen < %s
                          AND EXISTS (SELECT 1
                                        FROM {0}
                                       WHERE imei_norm = network_imeis.imei_norm)
                     GROUP BY tac
                    """ ) . format ( network_triplets_partition ) , [ start_date , end_date ] )
Helper function to calculate the top models by gross adds.
Helper function to calculate the top models by gross adds .
"""Helper function to calculate the top models by gross adds."""
db_config
month
year
operator