src/dirbs/utils.py
def filter_imei_list_sql_by_device_type(conn, exempted_device_types, imei_list_sql):
    """
    Function to return SQL filtering out exempted device types.

    Arguments:
        conn: dirbs db connection object
        exempted_device_types: exempted device types from config
        imei_list_sql: custom sql for imei lists
    Returns:
        formatted sql query
    """
    # If certain device types are exempted, first select the IMEIs passed in imei_list_sql query.
    # These IMEIs are then joined against GSMA TAC db to get their device type.
    # Finally, any IMEIs that belong to exempted device types are excluded.
    return sql.SQL("""SELECT imei_norm
                        FROM (SELECT imei_norm,
                                     SUBSTRING(imei_norm, 1, 8) AS tac
                                FROM ({0}) imeis) imeis_with_tac
                        JOIN gsma_data
                       USING (tac)
                       WHERE device_type NOT IN {1}
                    """).format(sql.SQL(imei_list_sql),
                                sql.Literal(tuple(exempted_device_types))).as_string(conn)

    Function to return SQL filtering out exempted device types.

    Arguments:
        conn: dirbs db connection object
        exempted_device_types: exempted device types from config
        imei_list_sql: custom sql for imei lists
    Returns:
        formatted sql query
    
Function to return SQL filtering out exempted device types.
Function to return SQL filtering out exempted device types .
def filter_imei_list_sql_by_device_type(conn, exempted_device_types, imei_list_sql):
    return sql.SQL("""SELECT imei_norm
                        FROM (SELECT imei_norm,
                                     SUBSTRING(imei_norm, 1, 8) AS tac
                                FROM ({0}) imeis) imeis_with_tac
                        JOIN gsma_data
                       USING (tac)
                       WHERE device_type NOT IN {1}
                    """).format(sql.SQL(imei_list_sql),
                                sql.Literal(tuple(exempted_device_types))).as_string(conn)
def filter_imei_list_sql_by_device_type ( conn , exempted_device_types , imei_list_sql ) : return sql . SQL ( """SELECT imei_norm
                        FROM (SELECT imei_norm,
                                     SUBSTRING(imei_norm, 1, 8) AS tac
                                FROM ({0}) imeis) imeis_with_tac
                        JOIN gsma_data
                       USING (tac)
                       WHERE device_type NOT IN {1}
                    """ ) . format ( sql . SQL ( imei_list_sql ) , sql . Literal ( tuple ( exempted_device_types ) ) ) . as_string ( conn )
Function to return SQL filtering out exempted device types.
Function to return SQL filtering out exempted device types .
"""
    Function to return SQL filtering out exempted device types.

    Arguments:
        conn: dirbs db connection object
        exempted_device_types: exempted device types from config
        imei_list_sql: custom sql for imei lists
    Returns:
        formatted sql query
    """ # If certain device types are exempted, first select the IMEIs passed in imei_list_sql query. # These IMEIs are then joined against GSMA TAC db to get their device type. # Finally, any IMEIs that belong to exempted device types are excluded.
formatted sql query
formatted sql query
conn
dirbs db connection object
dirbs db connection object
exempted_device_types
exempted device types from config
exempted device types from config
imei_list_sql
custom sql for imei lists
custom sql for imei lists