diff --git a/atdb/taskdatabase/config.py b/atdb/taskdatabase/config.py index acfde381938613709c5336ef82e264602ef89aa2..f50b238accc44b6d61e409e4cf84f09328bd9000 100644 --- a/atdb/taskdatabase/config.py +++ b/atdb/taskdatabase/config.py @@ -1,4 +1,3 @@ -VERSION = "Version 1.0.0 (14 jan 2020)" TASKS_PER_PAGE = 50 TASKS_PER_PAGE_SMALL = 10 diff --git a/atdb/taskdatabase/models.py b/atdb/taskdatabase/models.py index a87d4146937108f46572bba67891ea5980cbe021..b9eafb691900d53d30741754c96f9b378a82bb08 100644 --- a/atdb/taskdatabase/models.py +++ b/atdb/taskdatabase/models.py @@ -329,6 +329,18 @@ class Task(models.Model): @property def sasid_ingested_fraction(self): + """ + This 'property' of a task returns the fraction of queued/ingested tasks per SAS_ID + and a list of statusses of other tasks belonging to the same SAS_ID. + It is implemented as 'property', because then it can be used in html pages like this: + <td>{{ task.sasid_ingested_fraction.status }}</td> + <td>{{ task.sasid_ingested_fraction.completion }}%</td> + + A selection of statusses are considered 'queued', and another selection is considered 'ingested'. + The division of those 2 are returned as a 'completed %'. + A limited list of statusses for the other tasks that belong to this SAS_ID is also returned. + + """ result = {} statusses = {'scrubbed': 0, 'archiving': 0, 'archived': 0, 'finished': 0, 'suspended': 0,'discarded': 0, 'archived_failed': 0, 'finished_failed': 0} @@ -337,7 +349,7 @@ class Task(models.Model): for task in tasks: try: - statusses[task.status] = statusses[task.status] + 1 + statusses[task.status] += 1 except: pass diff --git a/atdb/taskdatabase/templates/taskdatabase/ingest/filter_buttons.html b/atdb/taskdatabase/templates/taskdatabase/ingest/filter_buttons.html index 917aaa803f3ace86fe770fdb8f727530ced3c199..782d2ec1b8d3cc5d9d4a1f2017873af694b56ef6 100644 --- a/atdb/taskdatabase/templates/taskdatabase/ingest/filter_buttons.html +++ b/atdb/taskdatabase/templates/taskdatabase/ingest/filter_buttons.html @@ -16,7 +16,7 @@ <tr> <td> {% include "taskdatabase/ingest/clear_filter_button.html" %} - <a href="{% url 'task-set-filter' 'scrubbed' 'ingest' %}" class="btn btn-secondary btn-sm" role="button">Queued</a> + <a href="{% url 'task-set-filter' 'scrubbed' 'ingest' %}" class="btn btn-secondary btn-sm" role="button">Queued (scrubbed)</a> <a href="{% url 'task-set-filter' 'archiving' 'ingest' %}" class="btn btn-secondary btn-sm" role="button"><i>Archiving</i></a> </td> diff --git a/atdb/taskdatabase/templates/taskdatabase/ingest/page.html b/atdb/taskdatabase/templates/taskdatabase/ingest/page.html index aeef24b3207ea439a728126b218d47208e7ffb75..cfcbcbd895b40c75236f8221e43e603dbd58c86b 100644 --- a/atdb/taskdatabase/templates/taskdatabase/ingest/page.html +++ b/atdb/taskdatabase/templates/taskdatabase/ingest/page.html @@ -11,7 +11,7 @@ <div class="col-12"> <h3>Ingest Queue</h3> - SAS_ID's with tasks <i>archiving</i> or queued (<i>scrubbed</i>) for ingest into LTA. + The ingest queue shows SASids with archiving and queued (scrubbed) tasks which are ingesting into the LTA {% include 'taskdatabase/ingest/filter_buttons.html' %} diff --git a/atdb/taskdatabase/tests/test_ingest_fraction.py b/atdb/taskdatabase/tests/test_ingest_fraction.py index fbfd4eb19b93a32374117e00cbe338a4fec02741..9a48ae93c2d7295c4c9af1a2b8126c767aee2017 100644 --- a/atdb/taskdatabase/tests/test_ingest_fraction.py +++ b/atdb/taskdatabase/tests/test_ingest_fraction.py @@ -16,7 +16,8 @@ class TestIngestFraction(TestCase): Task.objects.get_or_create(filter='a',sas_id=54321, status='archived', workflow=workflow_requantisation) Task.objects.get_or_create(filter='a',sas_id=54321, status='finished', workflow=workflow_requantisation) Task.objects.get_or_create(filter='b',sas_id=54321, status='finished', workflow=workflow_requantisation) - Task.objects.get_or_create(filter='b', sas_id=54321, status='discarded', workflow=workflow_requantisation) + Task.objects.get_or_create(filter='a', sas_id=54321, status='discarded', workflow=workflow_requantisation) + Task.objects.get_or_create(filter='a', sas_id=54321, status='archived_failed', workflow=workflow_requantisation) def test_ingest_fraction(self): # collapse all tasks into a single task for this sas_id @@ -26,5 +27,5 @@ class TestIngestFraction(TestCase): statusses = task.sasid_ingested_fraction['status'] completion = task.sasid_ingested_fraction['completion'] - self.assertEqual(statusses, {'scrubbed': 2, 'archiving': 1, 'archived': 1, 'finished': 2, 'discarded': 1}) - self.assertEqual(completion,50) + self.assertEqual(statusses, {'scrubbed': 2, 'archiving': 1, 'archived': 1, 'finished': 2, 'discarded': 1, 'archived_failed': 1}) + self.assertEqual(completion,43) diff --git a/atdb/taskdatabase/urls.py b/atdb/taskdatabase/urls.py index b22120029f0cdb3fdffa2cd28b23feec4c1859f9..f292639079a899f970f26da8bc94f9dd50d373d5 100644 --- a/atdb/taskdatabase/urls.py +++ b/atdb/taskdatabase/urls.py @@ -19,7 +19,7 @@ urlpatterns = [ path('validation', views.ShowValidationPage.as_view(), name='validation'), path('failures', views.ShowFailuresPage.as_view(), name='failures'), path('discarded', views.ShowDiscardedPage.as_view(), name='discarded'), - path('ingest', views.ShowIngestPage.as_view(), name='ingest'), + path('ingest', views.ShowIngestQPage.as_view(), name='ingest'), path('finished', views.ShowFinishedPage.as_view(), name='finished'), path('task_details/<int:id>/<page>', views.TaskDetails, name='task-details'), diff --git a/atdb/taskdatabase/views.py b/atdb/taskdatabase/views.py index c6cb9235324b45cc80eea81b232195b29b0f5f2d..c3d36016908476241f35c1009ed446e2f1d56b53 100644 --- a/atdb/taskdatabase/views.py +++ b/atdb/taskdatabase/views.py @@ -442,7 +442,7 @@ class ShowDiscardedPage(ListView): return tasks -class ShowIngestPage(ListView): +class ShowIngestQPage(ListView): """ This shows aggregated tasks per sas_id that are queued for ingest or archiving Note that the global filter is also applied @@ -488,7 +488,7 @@ class ShowIngestPage(ListView): class ShowFinishedPage(ListView): """ - This shows the tasks that are archived + This shows the tasks that are finished Note that the global filter is also applied """ template_name = 'taskdatabase/archived/page.html' @@ -1391,7 +1391,7 @@ def ChangePrioritySasID(request, pk, priority_change, page=0): task.priority = priority task.save() - return redirect('ingest') + return redirect_with_params('ingest', '?page=' + page)