Skip to content

Commit

Permalink
Add ability to exclude related frames from certain frame types
Browse files Browse the repository at this point in the history
BPMs, for instance, have up to hundreds of thousands of related frames. BANZAI queries for these frequently and we don't need related frames in the response, so it's wasteful for us to include them.
  • Loading branch information
mgdaily committed Oct 7, 2024
1 parent 298597d commit faeb484
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion archive/frames/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import json
from django.contrib.gis.db import models
from django.forms.models import model_to_dict
from django.conf import settings

from ocs_archive.storage.filestorefactory import FileStoreFactory
from ocs_archive.settings import settings as archive_settings
Expand Down Expand Up @@ -158,7 +159,10 @@ def as_dict(self, include_thumbnails=False):

if self.area:
ret_dict['area'] = json.loads(self.area.geojson)
ret_dict['related_frames'] = list(self.related_frames.all().values_list('id', flat=True))
if self.configuration_type in settings.EXCLUDE_RELATED_FRAME_TYPES:
ret_dict['related_frames'] = []
else:
ret_dict['related_frames'] = list(self.related_frames.all().values_list('id', flat=True))
return ret_dict


Expand Down
1 change: 1 addition & 0 deletions archive/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@
CONFIGDB_URL = os.getenv('CONFIGDB_URL', '')
CONFIGURATION_TYPES = get_tuple_from_environment('CONFIGURATION_TYPES', 'BIAS,DARK,EXPOSE,SPECTRUM,LAMPFLAT,SKYFLAT,STANDARD,TRAILED,GUIDE,EXPERIMENTAL,CATALOG')
SCIENCE_CONFIGURATION_TYPES = get_tuple_from_environment('SCIENCE_CONFIGURATION_TYPES', 'EXPOSE,TARGET,SPECTRUM,CATALOG,OBJECT')
EXCLUDE_RELATED_FRAME_TYPES = get_tuple_from_environment('EXCLUDE_RELATED_FRAME_TYPES', 'BPM,')

# Additional Customization
ZIP_DOWNLOAD_FILENAME_BASE = os.getenv('ZIP_DOWNLOAD_FILENAME_BASE', 'ocs_archive_data')
Expand Down

0 comments on commit faeb484

Please sign in to comment.