def run_auto_analyse_uat(uat_job: UatJobResult, app: Flask) -> int:
    """Run names through the auto analyser and save the results."""
    names_list = RequestName.get_untested()

    count = 0
    for name in names_list:
        try:
            app.logger.debug(f'testing {name.name}...')
            result = send_to_auto_analyzer(name, app)
            result_json = result.json()
            name.auto_analyse_request_time = int(
                result.elapsed.total_seconds())
            name.uat_job_id = uat_job.id
            name.auto_analyse_response = result_json
            name.auto_analyse_result = result_json['status']
            if result_json['issues']:
                name.auto_analyse_issue_text = result_json['issues'][0][
                    'line1']
                name.auto_analyse_issue_type = result_json['issues'][0][
                    'issue_type']
                if result_json['issues'][0]['conflicts']:
                    name.auto_analyse_conflict1 = result_json['issues'][0][
                        'conflicts'][0]['name']
            set_uat_result(name)
            name.save()
            app.logger.debug(
                f'{name.name} auto analyse time: {name.auto_analyse_request_time}'
            )

            count += 1
            if count == app.config['MAX_ROWS']:
                break
        except Exception as err:
            name.uat_result = RequestName.Results.ERROR.value
            name.uat_job_id = uat_job.id
            name.save()
            app.logger.error(err)
            app.logger.debug('skipping this name due to error.')
            continue

    return count
            name.save()
            app.logger.error(err)
            app.logger.debug('skipping this name due to error.')
            continue

    return count


if __name__ == '__main__':
    try:
        app = create_app()
        uat_type = app.config['UAT_TYPE']
        app.logger.debug(f'Running {uat_type}...')

        # delete any previously queued untested names (refresh the queue of names to test)
        for name in RequestName.get_untested():
            db.session.delete(name)

        if app.config['CSV_FILE'] and app.config['PREV_JOB_ID']:
            app.logger.error(
                'CSV_FILE and PREV_JOB_ID set in config. This is not handled, please only set one of these values.'
            )
            app.logger.debug(
                'CSV_FILE will take precedence (PREV_JOB_ID will be ignored).')

        excluded_names = \
            get_names_list_from_csv(app.config['EXCLUDED_NAMES']) if app.config['EXCLUDED_NAMES'] else []
        prioritized_names = get_names_list_from_csv(
            app.config['CSV_FILE']) if app.config['CSV_FILE'] else None
        if not prioritized_names:
            prioritized_names = \