code: def percent_pareto_durations(records, percentage=0.8):
      
      if len(records) == 0:
          return None
  
      user_count = defaultdict(int)
      for r in records:
          if r.interaction == "call":
              user_count[r.correspondent_id] += r.call_duration
  
      target = int(math.ceil(sum(user_count.values()) * percentage))
      user_sort = sorted(user_count.keys(), key=lambda x: user_count[x])
  
      while target > 0 and len(user_sort) > 0:
          user_id = user_sort.pop()
          target -= user_count[user_id]
  
      return (len(user_count) - len(user_sort)) / len(records)
docs: The percentage of user's contacts that account for 80% of its total time
      spend on the phone. Optionally takes a percentage argument as a decimal
      (e.g., .8 for 80%).