src/dirbs/reports/stats_generator.py
def _monthly_network_triplets_partition(*, conn, month, year, operator=None):
    """Calculates which triplets partition should be queries based on operator (or lack of)."""
    if operator is None:
        # If operator is None, return back a country partition
        partition_name = part_utils.monthly_network_triplets_country_partition(month=month, year=year)
        base_tbl_type = 'monthly_network_triplets_country'
    else:
        partition_name = part_utils.monthly_network_triplets_per_mno_partition(operator_id=operator,
                                                                               month=month, year=year)
        base_tbl_type = 'monthly_network_triplets_per_mno'

    partition_id = sql.Identifier(partition_name)
    with conn.cursor() as cursor:
        cursor.execute(utils.table_exists_sql(), [partition_name])
        if not cursor.fetchone().exists:
            # Fake a partition if one does not exist so that we don't need to do checks throughout the module in
            # each check
            partition_name = 'report_temp_{0}'.format(partition_name)
            cursor.execute(sql.SQL('CREATE TEMP TABLE IF NOT EXISTS {0} (LIKE {1})')
                           .format(partition_id, sql.Identifier(base_tbl_type)))

    return partition_id
Calculates which triplets partition should be queries based on operator (or lack of).
Calculates which triplets partition should be queries based on operator (or lack of).
Calculates which triplets partition should be queries based on operator ( or lack of ) .
def _monthly_network_triplets_partition(*, conn, month, year, operator=None):
    if operator is None:
        partition_name = part_utils.monthly_network_triplets_country_partition(month=month, year=year)
        base_tbl_type = 'monthly_network_triplets_country'
    else:
        partition_name = part_utils.monthly_network_triplets_per_mno_partition(operator_id=operator,
                                                                               month=month, year=year)
        base_tbl_type = 'monthly_network_triplets_per_mno'
    partition_id = sql.Identifier(partition_name)
    with conn.cursor() as cursor:
        cursor.execute(utils.table_exists_sql(), [partition_name])
        if not cursor.fetchone().exists:
            partition_name = 'report_temp_{0}'.format(partition_name)
            cursor.execute(sql.SQL('CREATE TEMP TABLE IF NOT EXISTS {0} (LIKE {1})')
                           .format(partition_id, sql.Identifier(base_tbl_type)))
    return partition_id
def _monthly_network_triplets_partition ( * , conn , month , year , operator = None ) : if operator is None : partition_name = part_utils . monthly_network_triplets_country_partition ( month = month , year = year ) base_tbl_type = 'monthly_network_triplets_country' else : partition_name = part_utils . monthly_network_triplets_per_mno_partition ( operator_id = operator , month = month , year = year ) base_tbl_type = 'monthly_network_triplets_per_mno' partition_id = sql . Identifier ( partition_name ) with conn . cursor ( ) as cursor : cursor . execute ( utils . table_exists_sql ( ) , [ partition_name ] ) if not cursor . fetchone ( ) . exists : partition_name = 'report_temp_{0}' . format ( partition_name ) cursor . execute ( sql . SQL ( 'CREATE TEMP TABLE IF NOT EXISTS {0} (LIKE {1})' ) . format ( partition_id , sql . Identifier ( base_tbl_type ) ) ) return partition_id
Calculates which triplets partition should be queries based on operator (or lack of).
Calculates which triplets partition should be queries based on operator ( or lack of ) .
"""Calculates which triplets partition should be queries based on operator (or lack of).""" # If operator is None, return back a country partition # Fake a partition if one does not exist so that we don't need to do checks throughout the module in # each check
conn
month
year
operator