diff --git a/SAS/TMSS/backend/src/tmss/tmssapp/migrations/0048_indices.py b/SAS/TMSS/backend/src/tmss/tmssapp/migrations/0048_indices.py new file mode 100644 index 0000000000000000000000000000000000000000..45953a20e3c9a3ee8817d42e4ae0ef6ec53cc8a8 --- /dev/null +++ b/SAS/TMSS/backend/src/tmss/tmssapp/migrations/0048_indices.py @@ -0,0 +1,53 @@ +# Generated by Django 3.0.9 on 2023-09-13 15:53 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('tmssapp', '0047_schedulingconstraintsweightfactor'), + ] + + operations = [ + migrations.AlterField( + model_name='schedulingunitblueprint', + name='observed_start_time', + field=models.DateTimeField(db_index=True, default=None, editable=False, help_text='The earliest on_sky_start_time of all the finished/observed observation tasks.', null=True), + ), + migrations.AlterField( + model_name='schedulingunitblueprint', + name='observed_stop_time', + field=models.DateTimeField(db_index=True, default=None, editable=False, help_text='The latest on_sky_stop_time of all the finished/observed observation tasks.', null=True), + ), + migrations.AlterField( + model_name='schedulingunitblueprint', + name='obsolete_since', + field=models.DateTimeField(db_index=True, default=None, editable=False, help_text='When was the first of the subtask(s) marked obsolete, or NULL if not obsolete (NULLable).', null=True), + ), + migrations.AlterField( + model_name='schedulingunitblueprint', + name='on_sky_start_time', + field=models.DateTimeField(db_index=True, default=None, editable=False, help_text='The earliest on_sky_start_time of all the observation tasks.', null=True), + ), + migrations.AlterField( + model_name='schedulingunitblueprint', + name='on_sky_stop_time', + field=models.DateTimeField(db_index=True, default=None, editable=False, help_text='The latest on_sky_stop_time of all the observation tasks.', null=True), + ), + migrations.AlterField( + model_name='schedulingunitblueprint', + name='process_start_time', + field=models.DateTimeField(db_index=True, default=None, editable=False, help_text='The earliest process_start_time of all the tasks.', null=True), + ), + migrations.AlterField( + model_name='schedulingunitblueprint', + name='process_stop_time', + field=models.DateTimeField(db_index=True, default=None, editable=False, help_text='The latest process_stop_time of all the tasks.', null=True), + ), + migrations.AlterField( + model_name='schedulingunitblueprint', + name='results_accepted', + field=models.BooleanField(db_index=True, default=None, help_text='boolean (default None) which indicates whether this unit was accepted as successful or not.', null=True), + ), + ] diff --git a/SAS/TMSS/backend/src/tmss/tmssapp/models/specification.py b/SAS/TMSS/backend/src/tmss/tmssapp/models/specification.py index 5ac21bcca828a7eb3abed22fd8fc343b3033dd9d..5edd16e6c822a04b35994341fa6518cf7bcf9b2c 100644 --- a/SAS/TMSS/backend/src/tmss/tmssapp/models/specification.py +++ b/SAS/TMSS/backend/src/tmss/tmssapp/models/specification.py @@ -1242,18 +1242,18 @@ class SchedulingUnitBlueprint(ProjectPropertyMixin, TemplateSchemaMixin, Schedul # these start/stop times are aggregated results over this task's start/stop times # they are computed/updated in the database using sql triggers upon subtask inserts/updates. - process_start_time = DateTimeField(null=True, default=None, editable=False, help_text='The earliest process_start_time of all the tasks.') - process_stop_time = DateTimeField(null=True, default=None, editable=False, help_text='The latest process_stop_time of all the tasks.') - on_sky_start_time = DateTimeField(null=True, default=None, editable=False, help_text='The earliest on_sky_start_time of all the observation tasks.') - on_sky_stop_time = DateTimeField(null=True, default=None, editable=False, help_text='The latest on_sky_stop_time of all the observation tasks.') - observed_start_time = DateTimeField(null=True, default=None, editable=False, help_text='The earliest on_sky_start_time of all the finished/observed observation tasks.') - observed_stop_time = DateTimeField(null=True, default=None, editable=False, help_text='The latest on_sky_stop_time of all the finished/observed observation tasks.') + process_start_time = DateTimeField(null=True, default=None, editable=False, db_index=True, help_text='The earliest process_start_time of all the tasks.') + process_stop_time = DateTimeField(null=True, default=None, editable=False, db_index=True, help_text='The latest process_stop_time of all the tasks.') + on_sky_start_time = DateTimeField(null=True, default=None, editable=False, db_index=True, help_text='The earliest on_sky_start_time of all the observation tasks.') + on_sky_stop_time = DateTimeField(null=True, default=None, editable=False, db_index=True, help_text='The latest on_sky_stop_time of all the observation tasks.') + observed_start_time = DateTimeField(null=True, default=None, editable=False, db_index=True, help_text='The earliest on_sky_start_time of all the finished/observed observation tasks.') + observed_stop_time = DateTimeField(null=True, default=None, editable=False, db_index=True, help_text='The latest on_sky_stop_time of all the finished/observed observation tasks.') on_sky_duration = DurationField(null=True, editable=False, help_text='The total scheduled/actual duration the observation tasks were on sky (NULLable).') observed_duration = DurationField(null=True, editable=False, help_text='The total actual duration that the finished/observed observation tasks were on sky (NULLable).') duration = DurationField(null=True, editable=False, help_text='The scheduled/actual duration for the full task (NULLable).') # obsolete_since and status are also computed/updated in the database using sql triggers upon subtask inserts/updates. - obsolete_since = DateTimeField(null=True, default=None, editable=False, help_text='When was the first of the subtask(s) marked obsolete, or NULL if not obsolete (NULLable).') + obsolete_since = DateTimeField(null=True, default=None, editable=False, db_index=True, help_text='When was the first of the subtask(s) marked obsolete, or NULL if not obsolete (NULLable).') status = ForeignKey('SchedulingUnitStatus', null=False, editable=False, default='defined', on_delete=PROTECT, help_text='The SchedulingUnit status - derived from the combined task statuses.') # please note that the most fields below are immutable at db level (See SQL triggers) @@ -1269,7 +1269,7 @@ class SchedulingUnitBlueprint(ProjectPropertyMixin, TemplateSchemaMixin, Schedul scheduling_constraints_doc = JSONField(help_text='Scheduling Constraints for this run.', null=True) scheduling_constraints_template = ForeignKey('SchedulingConstraintsTemplate', on_delete=CASCADE, null=True, help_text='Schema used for scheduling_constraints_doc.') interrupts_telescope = BooleanField(default=False, null=False, help_text='boolean (default FALSE), which indicates whether this observation was triggered (responsive telescope)') - results_accepted = BooleanField(default=None, null=True, help_text='boolean (default None) which indicates whether this unit was accepted as successful or not.') + results_accepted = BooleanField(default=None, null=True, db_index=True, help_text='boolean (default None) which indicates whether this unit was accepted as successful or not.') global_identifier = OneToOneField('SIPidentifier', null=False, editable=False, on_delete=PROTECT, help_text='The global unique identifier for LTA SIP.') path_to_project = 'draft__scheduling_set__project' placed = BooleanField(default=False, db_index=True, null=False, help_text='Was this unit placed by the scheduler, or are the scheduled_start/stop_time just best guesses?') diff --git a/SAS/TMSS/backend/src/tmss/tmssapp/viewsets/specification.py b/SAS/TMSS/backend/src/tmss/tmssapp/viewsets/specification.py index 5906a898d156ab56da522877128ef62baa655a65..b3f5710d0e33c6d73082151af2b651a62d7f67cb 100644 --- a/SAS/TMSS/backend/src/tmss/tmssapp/viewsets/specification.py +++ b/SAS/TMSS/backend/src/tmss/tmssapp/viewsets/specification.py @@ -311,10 +311,8 @@ class ReservationPropertyFilter(property_filters.PropertyFilterSet): id_min = filters.NumberFilter(field_name='id', lookup_expr='gte') id_max = filters.NumberFilter(field_name='id', lookup_expr='lte') project = filters.CharFilter(field_name='project__name', lookup_expr='icontains') - start_time_min = filters.DateTimeFilter(field_name='start_time', lookup_expr='gte') - start_time_max = filters.DateTimeFilter(field_name='start_time', lookup_expr='lte') - stop_time_min = filters.DateTimeFilter(field_name='stop_time', lookup_expr='gte') - stop_time_max = filters.DateTimeFilter(field_name='stop_time', lookup_expr='lte') + start_time = filters.IsoDateTimeFromToRangeFilter(field_name='start_time') + stop_time = filters.IsoDateTimeFromToRangeFilter(field_name='stop_time') stop_time_isnull = filters.BooleanFilter(field_name='stop_time', lookup_expr='isnull') duration_min = property_filters.PropertyNumberFilter(field_name='duration', lookup_expr='gte') duration_max = property_filters.PropertyNumberFilter(field_name='duration', lookup_expr='lte') @@ -923,8 +921,8 @@ class SchedulingUnitBlueprintSlimPropertyFilter(property_filters.PropertyFilterS '''A small 'slim' PropertyFilterSet for the most relevant properties.''' on_sky_start_time = filters.IsoDateTimeFromToRangeFilter(field_name='on_sky_start_time') on_sky_stop_time = filters.IsoDateTimeFromToRangeFilter(field_name='on_sky_stop_time') - scheduled_start_time = filters.IsoDateTimeFromToRangeFilter(field_name='scheduled_start_time') - scheduled_stop_time = filters.IsoDateTimeFromToRangeFilter(field_name='scheduled_stop_time') + process_start_time = filters.IsoDateTimeFromToRangeFilter(field_name='process_start_time') + process_stop_time = filters.IsoDateTimeFromToRangeFilter(field_name='process_stop_time') project = filters.CharFilter(field_name='draft__scheduling_set__project__name', lookup_expr='icontains') status = filters.MultipleChoiceFilter(field_name='status', choices=[(c.value, c.value) for c in models.SchedulingUnitStatus.Choices]) id = NumberInFilter(field_name='id', lookup_expr='in')