<commit_before>class ServersController < ApplicationController
  def show
    de_ip = Rails.env.production? ? 'localhost' : 'de.qlrace.com'
    ips = [de_ip, 'tx.qlrace.com', 'au.qlrace.com']
    ports = [27_960, 27_961]
    @servers = []
    ips.each do |ip|
      ports.each do |port|
        begin
          server = SourceServer.new(ip, port)
          ping = server.ping
          info = server.server_info
        rescue SocketError, Errno::ECONNREFUSED, SteamCondenser::TimeoutError
          next
        end
        name = info[:server_name]
        address = ip == 'localhost' ? "de.qlrace.com:#{port}" : "#{ip}:#{port}"
        map = info[:map_name].downcase
        num_players = "#{info[:number_of_players]}/#{info[:max_players]}"
        players = []
        server.players.each do |name, player|
          name_clean = name.gsub /\^[0-9]/, ''
          time = player.score == 2_147_483_647 ? 0 : player.score
          players << { name: name_clean, time: time }
          players.sort_by! { |k| k[:time] }
        end
        @servers << { name: name, address: address, map: map,
                      num_players: num_players, players: players }
      end
    end
  end
end
<commit_msg>Fixed ordering of players on server list<commit_after>class ServersController < ApplicationController
  def show
    de_ip = Rails.env.production? ? 'localhost' : 'de.qlrace.com'
    ips = [de_ip, 'tx.qlrace.com', 'au.qlrace.com']
    ports = [27_960, 27_961]
    @servers = []
    ips.each do |ip|
      ports.each do |port|
        begin
          server = SourceServer.new(ip, port)
          ping = server.ping
          info = server.server_info
        rescue SocketError, Errno::ECONNREFUSED, SteamCondenser::TimeoutError
          next
        end
        name = info[:server_name]
        address = ip == 'localhost' ? "de.qlrace.com:#{port}" : "#{ip}:#{port}"
        map = info[:map_name].downcase
        num_players = "#{info[:number_of_players]}/#{info[:max_players]}"
        players = []
        server.players.each do |name, player|
          name_clean = name.gsub /\^[0-9]/, ''
          time = player.score == -1 or player.score == 0 ? 2_147_483_647 : player.score
          players << { name: name_clean, time: time }
          players.sort_by! { |k| k[:time] }
        end
        @servers << { name: name, address: address, map: map,
                      num_players: num_players, players: players }
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.13523421588594706, 'fraction_numerical': 0.019144602851323828, 'mean_word_length': 2.2104575163398694, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2216588', 'n_tokens_mistral': 832, 'n_tokens_neox': 801, 'n_words': 179}