def get_last_data(
        self, state: StateManager, table_name=None, company_name_flag=False, checkpoint_query=CHECKPOINT_DATA_QUERY
    ):
        """Fetch last data from the checkpoint file.

        Args:
            state (StateManager): StateManager instance.
            table_name (str): Table name for the checkpoint file.
            company_name_flag (bool): Flag indicating if the company name is requested.
            checkpoint_query (str): Query for fetching checkpoint data from table.default query is CHECKPOINT_DATA_QUERY

        Returns:
            None/json: Last data from the checkpoint file or None.
            str: company name if company_name_flag is True
        """
        try:
            last_data = state.get()
            if last_data:
                if company_name_flag:
                    company_name = json.loads(last_data).get("company_name")
                    return company_name
                return json.loads(last_data)
            else:
                applogger.debug("{} GET LAST DATA: Checkpoint is not available.".format(LOGS_STARTS_WITH))
                return None
        except json.decoder.JSONDecodeError as error:
            applogger.error("{} GET LAST DATA: JSONDecodeError: {}".format(LOGS_STARTS_WITH, error))
            if company_name_flag:
                table = "{}_{}".format(table_name, "Company_Checkpoint")
            else:
                table = "{}_{}".format(table_name, "Checkpoint")
            applogger.debug("{} Fetching Checkpoint data from table: {}".format(LOGS_STARTS_WITH, table))
            logs_data, logs_flag = get_logs_data(checkpoint_query.format(table))
            if logs_flag:
                return self.set_checkpoint_file_content(state, logs_data, company_flag=company_name_flag)
            else:
                return None
        except Exception as err:
            applogger.exception("{} GET LAST DATA Error: {}".format(LOGS_STARTS_WITH, err))
            raise BitSightException()
Fetch last data from the checkpoint file.

        Args:
            state (StateManager): StateManager instance.
            table_name (str): Table name for the checkpoint file.
            company_name_flag (bool): Flag indicating if the company name is requested.
            checkpoint_query (str): Query for fetching checkpoint data from table.default query is CHECKPOINT_DATA_QUERY

        Returns:
            None/json: Last data from the checkpoint file or None.
            str: company name if company_name_flag is True
        
Solutions/BitSight/Data Connectors/BitSightDataConnector/SharedCode/utils.py