module ScoreHelper

  # helper method to make finding a user's score fault-tolerant
  def user_score_old(user_id)
    @user_scores ||= {}
    user = @user_scores[user_id]
    user ? user[:full_score] : nil
  end

  def user_score(user_id)
    @user_scores ||= {}
    user = @user_scores[user_id] || {}
    { full_score: user[:full_score], audio_latency: user[:audio_latency], internet_score: user[:internet_score] }
  end

  def last_jam_audio_latency(user)
    user.last_jam_audio_latency ? user.last_jam_audio_latency.round : nil
  end
end

