Exemplo n.º 1
0
 def log_initial_day_framework_collection(self, day_framework_collection):
     for day_name, isoweekday in self.day_to_index.items():
         cardio_level = day_framework_collection.get_cardio_for_day_index(isoweekday)
         self._log("(Initial Day Framework) Cardio level on UTC %s is %s" % (day_name, cardio_level or "no cardio"))
         workout_component_ids = day_framework_collection.get_workout_components_for_day_index(isoweekday)
         component_str = ", ".join([WorkoutComponent.get_by_id(id).title for id in workout_component_ids])
         self._log("(Initial Day Framework) Workout components on %s: %s" % (day_name, component_str))
Exemplo n.º 2
0
    def get_total_time(self):
        total_time = 0.0
        workout_component_to_exercises = self._get_workout_component_to_exercises()
        for workout_component_id, exercise_list in workout_component_to_exercises.items():
            if workout_component_id == WorkoutComponent.FLEXIBILITY:
                continue
            workout_component = WorkoutComponent.get_by_id(workout_component_id)
            for _workout__exercise in exercise_list:
                seconds_rest = workout_component.get_rest(self.phase)
                minutes_rest = float(seconds_rest) / 60
                minutes_rest *= _workout__exercise.sets
                total_time += minutes_rest

                for _we in [_workout__exercise, _workout__exercise.second_exercise]:
                    if _we is None:
                        continue
                    exercise = Exercise.get_by_id(_we.exercise_id)
                    if exercise.timed:
                        total_time += _we.sets * SECONDS_FOR_TIMED_EXERCISE / 60.0
                    else:
                        total_reps = _we.reps * _we.sets
                        rep_minutes = total_reps * self.phase.tempo.seconds_per_rep / 60.0
                        total_time += rep_minutes
        total_time *= TIME_FUDGE_FACTOR
        return total_time
Exemplo n.º 3
0
 def log_filter_before_action(self, exercise_filter, action):
     self._log("About to discard exercises (%s), %s are available before action" % (action, exercise_filter.count()))
     workout_component_to_count = defaultdict(int)
     for exercise in exercise_filter.query:
         workout_component_to_count[exercise.workout_component_id] += 1
     workout_component_to_count = {WorkoutComponent.get_by_id(k).title: v for k, v in workout_component_to_count.items()}
     for k, v in workout_component_to_count.items():
         self._log("  %s: %s" % (k, v))
Exemplo n.º 4
0
    def log_available_superset_exercise(self, exercise_list):
        available_muscle_group_ids = []
        workout_component = "(No available exercises)"
        if exercise_list:
            workout_component = WorkoutComponent.get_by_id(exercise_list[0].workout_component_id).title

        self._log("Before Superset exercise selection, %s exercises are available for %s" % (len(exercise_list), workout_component))
        for exercise in exercise_list:
            available_muscle_group_ids.append(exercise.muscle_group_id)
        available_muscle_group_ids = list(set(available_muscle_group_ids))
        muscle_names = ", ".join([MuscleGroup.get_name_for_id(id) for id in available_muscle_group_ids])
        self._log("Available superset muscle groups: %s" % muscle_names)
Exemplo n.º 5
0
 def to_json(self):
     json_dict = {
         "off_day": False,
         "visited": False,
         "workout_components": [],
         "phase": self.phase.to_json(),
         "cardio": self.cardio_session.to_json() if self.cardio_session else None,
     }
     workout_component_to_exercises = self._get_workout_component_to_exercises()
     for workout_component_id in WorkoutComponent.WORKOUT_ORDER:
         exercise_list = workout_component_to_exercises.get(workout_component_id)
         if exercise_list:
             workout_component = WorkoutComponent.get_by_id(workout_component_id)
             exercise_json_list = [self._workout__exercise_to_json(_w_e) for _w_e in exercise_list]
             exercise_json_list = [e for e in exercise_json_list if e is not None]
             json_dict["workout_components"].append({
                 "workout_component": workout_component.to_json(),
                 "rest": workout_component.get_rest(self.phase),
                 "exercises": exercise_json_list
             })
     return json_dict
Exemplo n.º 6
0
 def log_component_filter(self, workout_component_id, exercise_filter):
     component_title = WorkoutComponent.get_by_id(workout_component_id).title
     self._log("For %s, %s exercises available" % (component_title, exercise_filter.count()))
Exemplo n.º 7
0
 def log_no_more_for_component(self, workout_component_id, exception):
     workout_component = WorkoutComponent.get_by_id(workout_component_id).title
     self._log("Not commiting anymore exercises for %s (%s)" % (workout_component, exception))
Exemplo n.º 8
0
 def log_dead_end_for_component(self, workout_component_id):
     workout_component = WorkoutComponent.get_by_id(workout_component_id).title
     self._log("No exercises available for current filter for %s" % workout_component)
Exemplo n.º 9
0
 def log_add_more_time(self, target_time, current_time, workout_component_id):
     workout_component = WorkoutComponent.get_by_id(workout_component_id).title
     self._log("Trying to add more time.  Current time is %s, target time is %s.  Adding for %s" %
             (current_time, target_time, workout_component))
Exemplo n.º 10
0
 def log_num_exercises(self, volume_info, num_exercises, workout_component_id):
     workout_component = WorkoutComponent.get_by_id(workout_component_id).title
     self._log("Volume for %s: Range is [%s, %s], selected %s" %
             (workout_component, volume_info.min_exercises, volume_info.max_exercises, num_exercises))
Exemplo n.º 11
0
 def log_start_workout(self, workout_component_ids):
     self._log("===========Starting workout generation=========")
     component_str = ", ".join([WorkoutComponent.get_by_id(id).title for id in workout_component_ids])
     if not workout_component_ids:
         component_str = "NONE"
     self._log("Workout components for this workout: %s" % component_str)