database/study_models.py
def _get_data_time_bin(self, earliest=True, only_after_epoch: bool = True,
                           only_before_now: bool = True) -> Optional[datetime]:
        """
        Return the earliest ChunkRegistry time bin datetime for this study.
        
        Note: As of 2021-07-01, running the query as a QuerySet filter or sorting the QuerySet can
              take upwards of 30 seconds. Doing the logic in python speeds this up tremendously.
        Args:
            earliest: if True, will return earliest datetime; if False, will return latest datetime
            only_after_epoch: if True, will filter results only for datetimes after the Unix epoch
                              (1970-01-01T00:00:00Z)
            only_before_now: if True, will filter results only for datetimes before now
        """
        time_bins = self.chunk_registries.values_list("time_bin", flat=True)
        comparator = operator.lt if earliest else operator.gt
        now = timezone.now()
        desired_time_bin = None
        for time_bin in time_bins:
            if only_after_epoch and time_bin.timestamp() <= 0:
                continue
            if only_before_now and time_bin > now:
                continue
            if desired_time_bin is None:
                desired_time_bin = time_bin
                continue
            if comparator(desired_time_bin, time_bin):
                continue
            desired_time_bin = time_bin
        return desired_time_bin

        Return the earliest ChunkRegistry time bin datetime for this study.
        
        Note: As of 2021-07-01, running the query as a QuerySet filter or sorting the QuerySet can
              take upwards of 30 seconds. Doing the logic in python speeds this up tremendously.
        Args:
            earliest: if True, will return earliest datetime; if False, will return latest datetime
            only_after_epoch: if True, will filter results only for datetimes after the Unix epoch
                              (1970-01-01T00:00:00Z)
            only_before_now: if True, will filter results only for datetimes before now
        
Return the earliest ChunkRegistry time bin datetime for this study.
Note: As of 2021-07-01, running the query as a QuerySet filter or sorting the QuerySet can
take upwards of 30 seconds. Doing the logic in python speeds this up tremendously.
Return the earliest ChunkRegistry time bin datetime for this study . Note : As of 2021 - 07 - 01 running the query as a QuerySet filter or sorting the QuerySet can take upwards of 30 seconds . Doing the logic in python speeds this up tremendously .
def _get_data_time_bin(self, earliest=True, only_after_epoch: bool = True,
                           only_before_now: bool = True) -> Optional[datetime]:
        time_bins = self.chunk_registries.values_list("time_bin", flat=True)
        comparator = operator.lt if earliest else operator.gt
        now = timezone.now()
        desired_time_bin = None
        for time_bin in time_bins:
            if only_after_epoch and time_bin.timestamp() <= 0:
                continue
            if only_before_now and time_bin > now:
                continue
            if desired_time_bin is None:
                desired_time_bin = time_bin
                continue
            if comparator(desired_time_bin, time_bin):
                continue
            desired_time_bin = time_bin
        return desired_time_bin
def _get_data_time_bin ( self , earliest = True , only_after_epoch : bool = True , only_before_now : bool = True ) -> Optional [ datetime ] : time_bins = self . chunk_registries . values_list ( "time_bin" , flat = True ) comparator = operator . lt if earliest else operator . gt now = timezone . now ( ) desired_time_bin = None for time_bin in time_bins : if only_after_epoch and time_bin . timestamp ( ) <= 0 : continue if only_before_now and time_bin > now : continue if desired_time_bin is None : desired_time_bin = time_bin continue if comparator ( desired_time_bin , time_bin ) : continue desired_time_bin = time_bin return desired_time_bin
Return the earliest ChunkRegistry time bin datetime for this study.
Return the earliest ChunkRegistry time bin datetime for this study .
"""
        Return the earliest ChunkRegistry time bin datetime for this study.
        
        Note: As of 2021-07-01, running the query as a QuerySet filter or sorting the QuerySet can
              take upwards of 30 seconds. Doing the logic in python speeds this up tremendously.
        Args:
            earliest: if True, will return earliest datetime; if False, will return latest datetime
            only_after_epoch: if True, will filter results only for datetimes after the Unix epoch
                              (1970-01-01T00:00:00Z)
            only_before_now: if True, will filter results only for datetimes before now
        """
self
earliest
if True, will return earliest datetime; if False, will return latest datetime
if True will return earliest datetime ; if False will return latest datetime
only_after_epoch
bool
if True, will filter results only for datetimes after the Unix epoch
(1970-01-01T00:00:00Z)
if True will filter results only for datetimes after the Unix epoch ( 1970 - 01 - 01T00 : 00 : 00Z )
only_before_now
bool
if True, will filter results only for datetimes before now
if True will filter results only for datetimes before now