src/dirbs/utils.py
def compute_analysis_end_date(conn, curr_date):
    """
    Function to get the end of the analysis window based on current operator data.

    Arguments:
        conn: dirbs db connection object
        curr_date: current date of the system to compute analysis end date with
    Returns:
        analysis end date
    """
    end_date = curr_date
    if end_date is None:
        # If current date is None, set analysis end date as the last day for which operator data exists."""
        with conn.cursor() as cursor:
            monthly_country_child_tbl_list = child_table_names(conn, 'monthly_network_triplets_country')
            year_month_list_in_child_tbls_records = table_invariants_list(conn, monthly_country_child_tbl_list,
                                                                          ['triplet_year', 'triplet_month'])
            year_month_tuple_list = [(x.triplet_year, x.triplet_month) for x in year_month_list_in_child_tbls_records]
            if len(year_month_tuple_list) > 0:
                year_month_tuple_list.sort(key=lambda x: (x[0], x[1]), reverse=True)
                latest_year, latest_month = year_month_tuple_list[0]
                cursor.execute(sql.SQL("""SELECT MAX(last_seen)
                                            FROM monthly_network_triplets_country
                                           WHERE triplet_year = %s
                                             AND triplet_month = %s"""), [latest_year, latest_month])
                end_date = cursor.fetchone()[0]

    # If there was no operator data imported, this can be None
    if end_date is None:
        end_date = datetime.date.today()

    return end_date + datetime.timedelta(days=1)

    Function to get the end of the analysis window based on current operator data.

    Arguments:
        conn: dirbs db connection object
        curr_date: current date of the system to compute analysis end date with
    Returns:
        analysis end date
    
Function to get the end of the analysis window based on current operator data.
Function to get the end of the analysis window based on current operator data .
def compute_analysis_end_date(conn, curr_date):
    end_date = curr_date
    if end_date is None:
        with conn.cursor() as cursor:
            monthly_country_child_tbl_list = child_table_names(conn, 'monthly_network_triplets_country')
            year_month_list_in_child_tbls_records = table_invariants_list(conn, monthly_country_child_tbl_list,
                                                                          ['triplet_year', 'triplet_month'])
            year_month_tuple_list = [(x.triplet_year, x.triplet_month) for x in year_month_list_in_child_tbls_records]
            if len(year_month_tuple_list) > 0:
                year_month_tuple_list.sort(key=lambda x: (x[0], x[1]), reverse=True)
                latest_year, latest_month = year_month_tuple_list[0]
                cursor.execute(sql.SQL("""SELECT MAX(last_seen)
                                            FROM monthly_network_triplets_country
                                           WHERE triplet_year = %s
                                             AND triplet_month = %s"""), [latest_year, latest_month])
                end_date = cursor.fetchone()[0]
    if end_date is None:
        end_date = datetime.date.today()
    return end_date + datetime.timedelta(days=1)
def compute_analysis_end_date ( conn , curr_date ) : end_date = curr_date if end_date is None : with conn . cursor ( ) as cursor : monthly_country_child_tbl_list = child_table_names ( conn , 'monthly_network_triplets_country' ) year_month_list_in_child_tbls_records = table_invariants_list ( conn , monthly_country_child_tbl_list , [ 'triplet_year' , 'triplet_month' ] ) year_month_tuple_list = [ ( x . triplet_year , x . triplet_month ) for x in year_month_list_in_child_tbls_records ] if len ( year_month_tuple_list ) > 0 : year_month_tuple_list . sort ( key = lambda x : ( x [ 0 ] , x [ 1 ] ) , reverse = True ) latest_year , latest_month = year_month_tuple_list [ 0 ] cursor . execute ( sql . SQL ( """SELECT MAX(last_seen)
                                            FROM monthly_network_triplets_country
                                           WHERE triplet_year = %s
                                             AND triplet_month = %s""" ) , [ latest_year , latest_month ] ) end_date = cursor . fetchone ( ) [ 0 ] if end_date is None : end_date = datetime . date . today ( ) return end_date + datetime . timedelta ( days = 1 )
Function to get the end of the analysis window based on current operator data.
Function to get the end of the analysis window based on current operator data .
"""
    Function to get the end of the analysis window based on current operator data.

    Arguments:
        conn: dirbs db connection object
        curr_date: current date of the system to compute analysis end date with
    Returns:
        analysis end date
    """ # If current date is None, set analysis end date as the last day for which operator data exists.""" # If there was no operator data imported, this can be None
analysis end date
analysis end date
conn
dirbs db connection object
dirbs db connection object
curr_date
current date of the system to compute analysis end date with
current date of the system to compute analysis end date with