old_contents: import datetime
  import re
  
  def analyse(comments):
  
      tracks = re.compile('\[([0-9]+)h([0-9]+)m\]')
      hours = 0
      minutes = 0
  
      for comment in comments:
          for track in tracks.findall(comment.body):
  
              minutes += int(track[0]) * 60
              minutes += int(track[1])
  
      if 0 < minutes:
          hours = int(minutes / 60)
          minutes %= 60
  
      return {
          'hours': hours,
          'minutes': minutes
      }
  
  def average(length, hours, minutes):
  
      minutes = int(((hours * 60) + minutes) / length)
  
      hours = int(minutes / 60)
      minutes %= 60
  
      return {
          'hours': hours,
          'minutes': minutes
      }
new_contents: import datetime
  import re
  
  def analyse(sprint, issue):
  
      start = datetime.datetime.strptime(sprint['startDate'], '%d/%b/%y %I:%M %p')
      end = datetime.datetime.strptime(sprint['endDate'], '%d/%b/%y %I:%M %p')
      tracks = re.compile('\[([0-9]+)h([0-9]+)m\]')
      minutes = 0
  
      for comment in issue.fields.comment.comments:
          created = datetime.datetime.strptime(re.sub(r'\..*$', '', comment.created), '%Y-%m-%dT%H:%M:%S')
  
          if not (start <= created <= end):
              continue
  
          for track in tracks.findall(comment.body):
  
              minutes += int(track[0]) * 60
              minutes += int(track[1])
  
      return minutes
  
  def format(minutes):
  
      hours = 0
  
      if 0 < minutes:
          hours = int(minutes / 60)
          minutes %= 60
  
      return (hours, minutes)
subject: use sprint instead of single ticket to search for time tracks