From 26daab9e48ad17d9f949d3c6113f61d78b8c48dc Mon Sep 17 00:00:00 2001 From: Thomas Druez Date: Wed, 2 Nov 2022 17:07:49 +0400 Subject: [PATCH] Refine the display or the current_step value #300 Signed-off-by: Thomas Druez --- ...{0019_run_current_step.py => 0026_run_current_step.py} | 8 ++++---- scanpipe/pipelines/__init__.py | 3 ++- scanpipe/templates/scanpipe/includes/run_status_tag.html | 6 +++++- scanpipe/views.py | 2 ++ 4 files changed, 13 insertions(+), 6 deletions(-) rename scanpipe/migrations/{0019_run_current_step.py => 0026_run_current_step.py} (55%) diff --git a/scanpipe/migrations/0019_run_current_step.py b/scanpipe/migrations/0026_run_current_step.py similarity index 55% rename from scanpipe/migrations/0019_run_current_step.py rename to scanpipe/migrations/0026_run_current_step.py index d3eb87f56..c9ec6454b 100644 --- a/scanpipe/migrations/0019_run_current_step.py +++ b/scanpipe/migrations/0026_run_current_step.py @@ -1,4 +1,4 @@ -# 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 @@ -6,13 +6,13 @@ 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), ), ] diff --git a/scanpipe/pipelines/__init__.py b/scanpipe/pipelines/__init__.py index 6fda93d5e..26ef8124a 100644 --- a/scanpipe/pipelines/__init__.py +++ b/scanpipe/pipelines/__init__.py @@ -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() diff --git a/scanpipe/templates/scanpipe/includes/run_status_tag.html b/scanpipe/templates/scanpipe/includes/run_status_tag.html index 1fb2616c0..68b8cbed3 100644 --- a/scanpipe/templates/scanpipe/includes/run_status_tag.html +++ b/scanpipe/templates/scanpipe/includes/run_status_tag.html @@ -1,5 +1,9 @@ {% if run.status == run.Status.RUNNING or run.status == run.Status.QUEUED %} - + {% if run.status == run.Status.RUNNING %} Running {% if display_current_step and run.current_step %} diff --git a/scanpipe/views.py b/scanpipe/views.py index d394808c8..f9a987c72 100644 --- a/scanpipe/views.py +++ b/scanpipe/views.py @@ -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)