Skip to content

Commit

Permalink
added retry all from search button to import summary page
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinDo committed Jul 26, 2024
1 parent 8a28afb commit e4b7676
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 19 deletions.
17 changes: 11 additions & 6 deletions src/common/db_IO.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/common/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ <h4 class="card-subcaption">Status details</h4>
<td><div class="Nellipsis" data-bs-toggle="tooltip" data-bs-title="{{ entry.message }}">{{ entry.message }}</div></td>
<td>
<form action="{{url_for('user.variant_import_summary', import_queue_id=import_queue_id, **request.args)}}" method="post">
<input class="visually-hidden" name="action" value="retry_one" type="text">
<input class="visually-hidden" name="import_variant_queue_id" type="text" value="{{entry.id}}">
<button class="btn btn-outline-primary" type="submit">Retry</button>
</form>
Expand All @@ -203,8 +204,18 @@ <h4 class="card-subcaption">Status details</h4>
</tbody>
</table>
</div>

<div id="tabnav-bottom" class="ssb">{{ pagination.links }}</div>

<div class="d-flex">
<div id="tabnav-bottom" class="ssb">{{ pagination.links }}</div>
<div class="flex-grow-1"></div>
<div>
<form action="{{url_for('user.variant_import_summary', import_queue_id = import_queue_id, **request.args)}}" method="post">
<input class="visually-hidden" name="action" value="retry_search" type="text">
<button class="btn btn-outline-primary" type="submit">Retry all</button>
</form>
</div>
</div>


</div>

Expand Down
34 changes: 24 additions & 10 deletions src/frontend_celery/webapp/user/user_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand All @@ -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"])
Expand Down

0 comments on commit e4b7676

Please sign in to comment.