database/schedule_models.py
def create_relative_schedules(timings: List[List[int]], survey: Survey) -> bool:
        """
        Creates new RelativeSchedule objects from a frontend-style list of interventions and times
        If you modify this please update create_relative_schedules_by_name in libs.copy_study too.
        """
        survey.relative_schedules.all().delete()
        if survey.deleted or not timings:
            return False

        duplicated = False
        for intervention_id, days_after, num_seconds in timings:
            # using get_or_create to catch duplicate schedules
            _, created = RelativeSchedule.objects.get_or_create(
                survey=survey,
                intervention=Intervention.objects.get(id=intervention_id),
                days_after=days_after,
                hour=num_seconds // 3600,
                minute=num_seconds % 3600 // 60,
            )
            if not created:
                duplicated = True

        return duplicated

        Creates new RelativeSchedule objects from a frontend-style list of interventions and times
        If you modify this please update create_relative_schedules_by_name in libs.copy_study too.
        
Creates new RelativeSchedule objects from a frontend-style list of interventions and times
If you modify this please update create_relative_schedules_by_name in libs.copy_study too.
Creates new RelativeSchedule objects from a frontend - style list of interventions and times If you modify this please update create_relative_schedules_by_name in libs . copy_study too .
def create_relative_schedules(timings: List[List[int]], survey: Survey) -> bool:
        survey.relative_schedules.all().delete()
        if survey.deleted or not timings:
            return False
        duplicated = False
        for intervention_id, days_after, num_seconds in timings:
            _, created = RelativeSchedule.objects.get_or_create(
                survey=survey,
                intervention=Intervention.objects.get(id=intervention_id),
                days_after=days_after,
                hour=num_seconds // 3600,
                minute=num_seconds % 3600 // 60,
            )
            if not created:
                duplicated = True
        return duplicated
def create_relative_schedules ( timings : List [ List [ int ] ] , survey : Survey ) -> bool : survey . relative_schedules . all ( ) . delete ( ) if survey . deleted or not timings : return False duplicated = False for intervention_id , days_after , num_seconds in timings : _ , created = RelativeSchedule . objects . get_or_create ( survey = survey , intervention = Intervention . objects . get ( id = intervention_id ) , days_after = days_after , hour = num_seconds // 3600 , minute = num_seconds % 3600 // 60 , ) if not created : duplicated = True return duplicated
Creates new RelativeSchedule objects from a frontend-style list of interventions and times
If you modify this please update create_relative_schedules_by_name in libs.copy_study too.
Creates new RelativeSchedule objects from a frontend - style list of interventions and times If you modify this please update create_relative_schedules_by_name in libs . copy_study too .
"""
        Creates new RelativeSchedule objects from a frontend-style list of interventions and times
        If you modify this please update create_relative_schedules_by_name in libs.copy_study too.
        """ # using get_or_create to catch duplicate schedules

timings
List[List[int]]
survey
Survey