Skip to content
Snippets Groups Projects
Commit 4abf5bbf authored by Nico Vermaas's avatar Nico Vermaas
Browse files

add is_summary field

parent b15464d0
No related branches found
No related tags found
1 merge request!343added mechanism and structure to check if a task is a 'summary' task
Pipeline #72850 passed
# Generated by Django 5.0 on 2024-02-20 12:28
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('taskdatabase', '0041_alter_task_activity'),
]
operations = [
migrations.AddField(
model_name='task',
name='is_summary',
field=models.BooleanField(default=False),
),
]
...@@ -88,7 +88,6 @@ def associate_task_with_activity(task): ...@@ -88,7 +88,6 @@ def associate_task_with_activity(task):
activity = Activity(sas_id=task.sas_id, activity = Activity(sas_id=task.sas_id,
project=task.project, project=task.project,
workflow_id = task.workflow.id,
filter=task.filter) filter=task.filter)
activity.save() activity.save()
...@@ -140,6 +139,7 @@ class Task(models.Model): ...@@ -140,6 +139,7 @@ class Task(models.Model):
# Task control properties # Task control properties
task_type = models.CharField(max_length=20, default="regular") task_type = models.CharField(max_length=20, default="regular")
is_summary = models.BooleanField(default=False)
filter = models.CharField(max_length=30, blank=True, null=True) filter = models.CharField(max_length=30, blank=True, null=True)
environment = models.CharField(max_length=255, blank=True, null=True) environment = models.CharField(max_length=255, blank=True, null=True)
new_status = models.CharField(max_length=50, default="defining", null=True) new_status = models.CharField(max_length=50, default="defining", null=True)
...@@ -202,6 +202,11 @@ class Task(models.Model): ...@@ -202,6 +202,11 @@ class Task(models.Model):
tasks_for_this_sasid = Task.objects.filter(sas_id=self.sas_id) tasks_for_this_sasid = Task.objects.filter(sas_id=self.sas_id)
self.calculated_qualities = qualities.calculate_qualities(self, tasks_for_this_sasid, quality_thresholds) self.calculated_qualities = qualities.calculate_qualities(self, tasks_for_this_sasid, quality_thresholds)
# nv:20feb2024, check if this task is a summary task
if (self.status != State.PROCESSED.value) & (self.new_status == State.PROCESSED.value):
#task.is_summary = algorithms.check_if_summary(self)
pass
# make sure that every task has an activity (also for backward compatibility) # make sure that every task has an activity (also for backward compatibility)
associate_task_with_activity(self) associate_task_with_activity(self)
......
...@@ -97,7 +97,7 @@ class TaskReadSerializer(serializers.ModelSerializer): ...@@ -97,7 +97,7 @@ class TaskReadSerializer(serializers.ModelSerializer):
class Meta: class Meta:
model = Task model = Task
fields = ['id','task_type','creationTime','filter', fields = ['id','task_type','is_summary','creationTime','filter',
'predecessor','predecessor_status','successors', 'predecessor','predecessor_status','successors',
'joined_input_tasks','joined_output_task','joined_status', 'joined_input_tasks','joined_output_task','joined_status',
'project','sas_id','priority','purge_policy','cleanup_policy','resume', 'project','sas_id','priority','purge_policy','cleanup_policy','resume',
......
...@@ -143,6 +143,10 @@ def update_activity(task): ...@@ -143,6 +143,10 @@ def update_activity(task):
activity.filter = task.filter activity.filter = task.filter
activity.save() activity.save()
if activity.workflow_id != task.workflow.id: try:
activity.workflow_id = task.workflow.id if activity.workflow_id != task.workflow.id:
activity.save() activity.workflow_id = task.workflow.id
\ No newline at end of file activity.save()
except:
# continue, workflow is not initially needed
logger.error(f'no workflow found for this task')
\ No newline at end of file
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
{% include 'taskdatabase/pagination.html' %} {% include 'taskdatabase/pagination.html' %}
</div> </div>
</div> </div>
<p class="footer"> Version 19 Feb 2024 <p class="footer"> Version 20 Feb 2024
</div> </div>
{% include 'taskdatabase/refresh.html' %} {% include 'taskdatabase/refresh.html' %}
......
...@@ -57,6 +57,7 @@ class TaskFilter(filters.FilterSet): ...@@ -57,6 +57,7 @@ class TaskFilter(filters.FilterSet):
fields = { fields = {
'task_type': ['exact', 'icontains', 'in'], 'task_type': ['exact', 'icontains', 'in'],
'is_summary': ['exact'],
'creationTime': ['icontains'], 'creationTime': ['icontains'],
'filter': ['exact', 'icontains'], 'filter': ['exact', 'icontains'],
'workflow__id': ['exact', 'icontains'], 'workflow__id': ['exact', 'icontains'],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment