diff --git a/atdb/taskdatabase/models.py b/atdb/taskdatabase/models.py index 35ac5ff9c6c71c90a76d1906ca13847bc51e6d6c..e13ffe38c472e6c6b9f5a23e8039de2d76adf4ea 100644 --- a/atdb/taskdatabase/models.py +++ b/atdb/taskdatabase/models.py @@ -30,7 +30,6 @@ class State(Enum): datetime_format_string = '%Y-%m-%dT%H:%M:%SZ' verified_statusses = ['stored','validated','scrubbed','archived','finished','suspended','discarded'] - class Workflow(models.Model): description = models.CharField(max_length=500, blank=True, null=True) tag = models.CharField(max_length=30, blank=True, null=True) @@ -278,6 +277,7 @@ class Task(models.Model): except: return None + @property def path_to_lta(self): try: @@ -292,6 +292,27 @@ class Task(models.Model): return False return True + @property + def sasid_finished_fraction(self): + size_archived = 0 + size_remaining = 0 + total_size = 0 + + tasks = Task.objects.filter(sas_id=self.sas_id) + + for task in tasks: + if task.status == State.FINISHED.value: + size_archived = size_archived + task.size_to_process + else: + size_remaining = size_remaining + task.size_to_process + total_size = total_size + task.size_to_process + + finished = {} + finished['fraction'] = round((size_archived / (size_remaining + size_archived)) * 100) + finished['total_size'] = total_size + finished['remaining'] = size_remaining + return finished + @property def joined_status(self): # if a task has joined_input_tasks, then check their status diff --git a/atdb/taskdatabase/templates/taskdatabase/failures/headers.html b/atdb/taskdatabase/templates/taskdatabase/failures/headers.html index 4e06b0e06dd4f0b43c8e3485b18c62b33f679a8a..f810f2fa4164b8684270d5a830411d7a8e9bcfa7 100644 --- a/atdb/taskdatabase/templates/taskdatabase/failures/headers.html +++ b/atdb/taskdatabase/templates/taskdatabase/failures/headers.html @@ -20,10 +20,13 @@ SAS_ID <a href="{% url 'sort-tasks' 'sas_id' 'failures' %}" class="btn btn-light btn-sm" role="button"><i class="fas fa-sort-down"></i></a> </th> + <th> <a href="{% url 'sort-tasks' '-filter' 'failures' %}" class="btn btn-light btn-sm" role="button"><i class="fas fa-sort-up"></i></a> Filter <a href="{% url 'sort-tasks' 'filter' 'failures' %}" class="btn btn-light btn-sm" role="button"><i class="fas fa-sort-down"></i></a> </th> + <th>Finished (SAS_ID)</th> + <th>Remaining (task / sas_id)</th> <th>Actions</th> </tr> \ No newline at end of file diff --git a/atdb/taskdatabase/templates/taskdatabase/failures/tasks.html b/atdb/taskdatabase/templates/taskdatabase/failures/tasks.html index c91d6c0bbb00a9e2153f6005ded5f93bcbc62b72..8175a58fa8e828eb022c1d0f79668ab121db89e3 100644 --- a/atdb/taskdatabase/templates/taskdatabase/failures/tasks.html +++ b/atdb/taskdatabase/templates/taskdatabase/failures/tasks.html @@ -36,7 +36,8 @@ <td>{{ task.sas_id }}</td> <td>{{ task.filter }} </td> - + <td>{{ task.sasid_finished_fraction.fraction }}% of {{ task.sasid_finished_fraction.total_size|filesizeformat }}</td> + <td>{{ task.size_to_process|filesizeformat }} / {{ task.sasid_finished_fraction.remaining|filesizeformat }}</td> <td> {% include "taskdatabase/failures/retry_buttons.html" %} diff --git a/atdb/taskdatabase/templates/taskdatabase/index.html b/atdb/taskdatabase/templates/taskdatabase/index.html index d2aeb48ba1548a57a942ba8f27878b6b2b2e04b3..7b43cb45192d76cfe4a9579f9a5d19b4c7fd735b 100644 --- a/atdb/taskdatabase/templates/taskdatabase/index.html +++ b/atdb/taskdatabase/templates/taskdatabase/index.html @@ -31,7 +31,7 @@ {% include 'taskdatabase/pagination.html' %} </div> </div> - <p class="footer"> Version 11 July 2023 + <p class="footer"> Version 13 July 2023 </div> {% include 'taskdatabase/refresh.html' %} diff --git a/atdb/taskdatabase/views.py b/atdb/taskdatabase/views.py index fd2065c182ab0444e21bd3d207be811db63c1729..84b38dd8b339f08c7d76ce24cb1456e7299c023a 100644 --- a/atdb/taskdatabase/views.py +++ b/atdb/taskdatabase/views.py @@ -1,6 +1,5 @@ import logging import json -from enum import Enum from . import config from django.contrib.auth.decorators import login_required