From 92632e34f8ee1fcfabd4aec68a1a7ee55601fed0 Mon Sep 17 00:00:00 2001 From: Dennis Priskorn <68460690+dpriskorn@users.noreply.github.com> Date: Thu, 24 Feb 2022 01:27:05 +0100 Subject: [PATCH] Implement fetching up to limit and asking in the end only. This saves time for the user and they can do other things while ItemSubjector fetches candidates to be reviewed. jobs.py: process_qid_into_job(): Remove asking get_validated_main_subjects_as_jobs(): Ask here instead depending on whether limit is set or not. --- src/helpers/jobs.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/helpers/jobs.py b/src/helpers/jobs.py index 7385866..761df9c 100644 --- a/src/helpers/jobs.py +++ b/src/helpers/jobs.py @@ -77,9 +77,9 @@ def process_qid_into_job(qid: str = None, raise ValueError("items.list was None") if len(items.list) > 0: # Remove duplicates - logger.info(f"{len(items.list)} before duplicate removal") + logger.warning(f"{len(items.list)} before duplicate removal") items.list = list(set(items.list)) - logger.info(f"{len(items.list)} after duplicate removal") + logger.warning(f"{len(items.list)} after duplicate removal") # Randomize the list items.random_shuffle_list() print_found_items_table(args=args, @@ -89,11 +89,7 @@ def process_qid_into_job(qid: str = None, items=items, suggestion=suggestion ) - answer = ask_add_to_job_queue(job) - if answer: - return job - else: - return None + return job else: console.print("No matching items found") return None @@ -172,7 +168,12 @@ def get_validated_main_subjects_as_jobs(args: argparse.Namespace = None, args=args, confirmation=args.no_confirmation) if job is not None: - batchjobs.jobs.append(job) + if args.no_ask_match_more_limit is None: + answer = ask_add_to_job_queue(job) + if answer: + batchjobs.jobs.append(job) + else: + batchjobs.jobs.append(job) logger.debug(f"joblist now has {len(batchjobs.jobs)} jobs") print_job_statistics(batchjobs=batchjobs) if len(subjects_not_picked_yet) > 0: @@ -192,4 +193,11 @@ def get_validated_main_subjects_as_jobs(args: argparse.Namespace = None, else: console.print("No more subjects in the list. Exiting.") break + if args.no_ask_match_more_limit is not None: + batchjobs_limit = BatchJobs(jobs=[]) + for job in batchjobs.jobs: + answer = ask_add_to_job_queue(job) + if answer: + batchjobs_limit.jobs.append(job) + return batchjobs_limit return batchjobs