diff --git a/SAS/TMSS/backend/src/tmss/tmssapp/models/specification.py b/SAS/TMSS/backend/src/tmss/tmssapp/models/specification.py index 3866957e785e367d027cc5459ff11620312b7215..540dc4d8639543a39a1a76d924609293f6c7cc04 100644 --- a/SAS/TMSS/backend/src/tmss/tmssapp/models/specification.py +++ b/SAS/TMSS/backend/src/tmss/tmssapp/models/specification.py @@ -496,6 +496,7 @@ class SchedulingUnitBlueprint(ProjectPropertyMixin, TemplateSchemaMixin, NamedCo INGESTING = "ingesting" SCHEDULED = "scheduled" SCHEDULABLE = "schedulable" + OBSOLETE = "obsolete" # todo: are many of these fields supposed to be immutable in the database? # Or are we fine to just not allow most users to change them? @@ -652,6 +653,9 @@ class SchedulingUnitBlueprint(ProjectPropertyMixin, TemplateSchemaMixin, NamedCo return SchedulingUnitBlueprint.Status.CANCELLED.value elif self._any_task_error(status_overview_counter): return SchedulingUnitBlueprint.Status.ERROR.value + elif self._any_task_obsolete(status_overview_counter): + # TODO: in TMSS-850 implement the various conditional aggregations for the 'obsolete' vs 'finished' states + return SchedulingUnitBlueprint.Status.OBSOLETE.value elif self._any_task_started_observed_finished(status_overview_counter): if not self._all_observation_task_observed_finished(status_overview_counter_per_type): return SchedulingUnitBlueprint.Status.OBSERVING.value @@ -688,6 +692,10 @@ class SchedulingUnitBlueprint(ProjectPropertyMixin, TemplateSchemaMixin, NamedCo def _any_task_error(status_overview_counter): return status_overview_counter["error"] > 0 + @staticmethod + def _any_task_obsolete(status_overview_counter): + return status_overview_counter["obsolete"] > 0 + @staticmethod def _any_task_started_observed_finished(status_overview_counter): return (status_overview_counter["started"] + status_overview_counter["observed"] + status_overview_counter["finished"]) > 0 @@ -1050,6 +1058,10 @@ class TaskBlueprint(ProjectPropertyMixin, TemplateSchemaMixin, NamedCommon): if any(s for s in subtasks if s['state'] == 'error'): return "error" + # TODO: in TMSS-850 implement the various conditional aggregations for the 'obsolete' vs 'finished' states + if any(s for s in subtasks if s['state'] == 'obsolete'): + return "obsolete" + observations = [s for s in subtasks if s['specifications_template__type_id'] == 'observation'] if observations and all(obs and obs['state'] in ('finishing', 'finished') for obs in observations): return "observed"