Skip to content

Commit

Permalink
Refine the display or the current_step value #300
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Druez <tdruez@nexb.com>
  • Loading branch information
tdruez committed Nov 2, 2022
1 parent dd8c4d4 commit 26daab9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# Generated by Django 4.0.6 on 2022-07-22 07:57
# Generated by Django 4.1.2 on 2022-11-02 12:41

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('scanpipe', '0018_codebaseresource_tag'),
("scanpipe", "0025_remove_discoveredpackage_last_modified_date_and_more"),
]

operations = [
migrations.AddField(
model_name='run',
name='current_step',
model_name="run",
name="current_step",
field=models.CharField(blank=True, max_length=256),
),
]
3 changes: 2 additions & 1 deletion scanpipe/pipelines/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ def execute(self):
step_name = step.__name__

# The `current_step` value is saved in the DB during the `self.log` call.
self.run.current_step = f"{current_index}/{steps_count} {step_name}"
self.run.current_step = f"{current_index}/{steps_count} {step_name}"[:256]

self.log(f"Step [{step_name}] starting")
start_time = timeit.default_timer()

Expand Down
6 changes: 5 additions & 1 deletion scanpipe/templates/scanpipe/includes/run_status_tag.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{% if run.status == run.Status.RUNNING or run.status == run.Status.QUEUED %}
<span class="tag is-info" hx-get="{% url 'run_status' run.uuid %}?current_status={{ run.status }}" hx-trigger="load delay:10s" hx-swap="outerHTML">
<span class="tag is-info"
hx-get="{% url 'run_status' run.uuid %}?current_status={{ run.status }}{% if display_current_step %}&display_current_step={{ display_current_step }}{% endif %}"
hx-trigger="load delay:10s"
hx-swap="outerHTML"
>
{% if run.status == run.Status.RUNNING %}
<i class="fas fa-spinner fa-pulse mr-1" aria-hidden="true"></i>Running
{% if display_current_step and run.current_step %}
Expand Down
2 changes: 2 additions & 0 deletions scanpipe/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1173,6 +1173,8 @@ def run_status_view(request, uuid):
if current_status and current_status != run.status:
context["status_changed"] = True

context["display_current_step"] = request.GET.get("display_current_step")

return render(request, template, context)


Expand Down

0 comments on commit 26daab9

Please # to comment.