code: def calculate_assigned_hours(semester=None, profiles=None):
      
      if semester is None:
          try:
              semester = Semester.objects.get(current=True)
          except (Semester.DoesNotExist, Semester.MultipleObjectsReturned):
              return
      if profiles is None:
          profiles = WorkshiftProfile.objects.filter(semester=semester)
  
      for profile in profiles:
          for pool_hours in profile.pool_hours.all():
              shifts = RegularWorkshift.objects.filter(
                  current_assignees=profile,
                  pool=pool_hours.pool,
                  active=True,
              )
              pool_hours.assigned_hours = sum(shift.hours for shift in shifts)
              pool_hours.save(update_fields=["assigned_hours"])
docs: Utility function to recalculate the assigned workshift hours. This function
      is meant to only be called from the manager shell, it is not referenced
      anywhere else in the workshift module.
  
      Parameters
      ----------
      semester : workshift.models.Semester, optional
      profiles : list of workshift.models.WorkshiftProfile, optional