You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: stats_report.rb
    path of file: ./repos/vets-api/modules/appeals_api/lib/appeals_api
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

module AppealsApi
  class StatsReport
    DATE_FORMAT = '%b%e, %Y'

    # [from, to] pairs to report transition times
    STATUS_TRANSITION_PAIRS = [
      %w[submitting submitted],
      %w[submitting error],

      %w[submitted processing
    
    def stats(update_record_pairs)
      return { mean: nil, median: nil } if update_record_pairs.empty?

      sum, values = update_record_pairs.reduce([0, []]) do |(s, v), (current, previous)|
        timespan = current.status_update_time - previous.status_update_time
        [s + timespan, v << timespan]
      end

      values.sort!
      middle = (values.count - 1) / 2.0

      {
        mean: sum / values.count,
        median: (values[middle.floor] + values[middle.ceil]) / 2.0
      }
    end