From e4b7676522fd1da9e41817cdf1715f5a2e5bed2b Mon Sep 17 00:00:00 2001 From: MarvinDo Date: Fri, 26 Jul 2024 12:28:16 +0200 Subject: [PATCH] added retry all from search button to import summary page --- src/common/db_IO.py | 17 ++++++---- src/common/paths.py | 2 +- .../user/variant_import_summary.html | 15 ++++++-- .../webapp/user/user_routes.py | 34 +++++++++++++------ 4 files changed, 49 insertions(+), 19 deletions(-) diff --git a/src/common/db_IO.py b/src/common/db_IO.py index fa9b84e0..42166a39 100644 --- a/src/common/db_IO.py +++ b/src/common/db_IO.py @@ -1964,16 +1964,21 @@ def get_imported_variants_page(self, comments, stati, vids, import_queue_id, pag new_constraints = "import_queue_id = %s" postfix = self.add_constraints_to_command(postfix, new_constraints) actual_information += (import_queue_id, ) - command = prefix + postfix + " ORDER BY requested_at DESC LIMIT %s, %s" - page_size = int(page_size) - page = int(page) - offset = (page - 1) * page_size - actual_information += (offset, page_size) - print(command % actual_information) + command = prefix + postfix + " ORDER BY requested_at DESC" + if page_size != "all": + command += " LIMIT %s, %s" + page_size = int(page_size) + page = int(page) + offset = (page - 1) * page_size + actual_information += (offset, page_size) + #print(command % actual_information) self.cursor.execute(command, actual_information) raw_results = self.cursor.fetchall() result = [self.convert_raw_import_variant_request(raw_result) for raw_result in raw_results] + if page_size == "all": + return result, len(result) + # get total number prefix = "SELECT COUNT(id) FROM import_variant_queue" command = prefix + postfix diff --git a/src/common/paths.py b/src/common/paths.py index 345d792d..5203dee0 100644 --- a/src/common/paths.py +++ b/src/common/paths.py @@ -43,7 +43,7 @@ def joinpaths(path, *paths): ngs_bits_path = joinpaths(toolsdir, "ngs-bits/bin") htslib_path = joinpaths(toolsdir, "htslib") automatic_classification_path = joinpaths(toolsdir, "herediclass") - automatic_classification_config_path = os.path.join(automatic_classification_path, "config_pejaver_mult_strength_production.yaml") # config_production.yaml + automatic_classification_config_path = os.path.join(automatic_classification_path, "config_pejaver_mult_strength_production.yaml") # "config_production.yaml" samtools_path = joinpaths(toolsdir, "samtools/samtools") # data diff --git a/src/frontend_celery/webapp/templates/user/variant_import_summary.html b/src/frontend_celery/webapp/templates/user/variant_import_summary.html index 716e74e6..fb2bd92d 100644 --- a/src/frontend_celery/webapp/templates/user/variant_import_summary.html +++ b/src/frontend_celery/webapp/templates/user/variant_import_summary.html @@ -194,6 +194,7 @@

Status details

{{ entry.message }}
+
@@ -203,8 +204,18 @@

Status details

- -
{{ pagination.links }}
+ +
+
{{ pagination.links }}
+
+
+
+ + +
+
+
+ diff --git a/src/frontend_celery/webapp/user/user_routes.py b/src/frontend_celery/webapp/user/user_routes.py index 463229a2..09789072 100644 --- a/src/frontend_celery/webapp/user/user_routes.py +++ b/src/frontend_celery/webapp/user/user_routes.py @@ -367,16 +367,28 @@ def variant_import_summary(import_queue_id): import_request = conn.get_import_request(import_queue_id) require_set(import_request) - if request.method == 'POST': - import_variant_queue_id = request.form.get('import_variant_queue_id') - require_valid(import_variant_queue_id, 'import_variant_queue', conn) + static_information = get_static_vis_information(conn) - tasks.retry_variant_import(import_variant_queue_id, session['user']['user_id'], session['user']['roles'], conn) - vid = conn.get_vid_from_import_variant_queue(import_variant_queue_id) - flash("Successfully requested reimport of vid " + str(vid) + ". It is processed in the background. If this page does not show a pending variant refresh to view changes.", "alert-success") - return redirect(url_for('user.variant_import_summary', import_queue_id = import_queue_id, **request.args)) + if request.method == 'POST': + action = request.form.get('action') + require_set(action) + if action == "retry_one": + import_variant_queue_id = request.form.get('import_variant_queue_id') + require_valid(import_variant_queue_id, 'import_variant_queue', conn) + + tasks.retry_variant_import(import_variant_queue_id, session['user']['user_id'], session['user']['roles'], conn) + vid = conn.get_vid_from_import_variant_queue(import_variant_queue_id) + flash("Successfully requested reimport of vid " + str(vid) + ". It is processed in the background. If this page does not show a pending variant refresh to view changes.", "alert-success") + return redirect(url_for('user.variant_import_summary', import_queue_id = import_queue_id, **request.args)) + if action == "retry_search": + imported_variants, total, page, page_size = get_vis_page(request.args, import_queue_id, static_information, conn, paginate = False) + for imported_variant in imported_variants: + import_variant_queue_id = imported_variant.id + tasks.retry_variant_import(import_variant_queue_id, session['user']['user_id'], session['user']['roles'], conn) + flash("Successfully requested reimport of " + str(len(imported_variants)) + " VIDs. If this page does not show a pending variant refresh to view changes.", "alert-success") + return redirect(url_for('user.variant_import_summary', import_queue_id = import_queue_id, **request.args)) - static_information = get_static_vis_information(conn) + imported_variants, total, page, page_size = get_vis_page(request.args, import_queue_id, static_information, conn) pagination = Pagination(page=page, per_page=page_size, total=total, css_framework='bootstrap5') @@ -396,9 +408,11 @@ def get_static_vis_information(conn: Connection): result["allowed_stati"] = conn.get_enumtypes("import_variant_queue", "status") return result -def get_vis_page(request_args, import_queue_id, static_information, conn: Connection): +def get_vis_page(request_args, import_queue_id, static_information, conn: Connection, paginate = True): page = request.args.get('page', static_information["default_page"]) - page_size = request.args.get('page_size', static_information["default_page_size"]) + page_size = "all" + if paginate: + page_size = request.args.get('page_size', static_information["default_page_size"]) comments = extract_comments_vis(request_args) stati = extract_stati_vis(request_args, static_information["allowed_stati"])