Permalink
Browse files

allow everyone to view the server/player statistics

  • Loading branch information...
1 parent 86082df commit 2d8bbf8fbec0c9b019dbc34a7e2af90166cc124e @Arie committed Jan 23, 2015
@@ -1,27 +1,26 @@
class PlayerStatisticsController < ApplicationController
- before_filter :require_admin
def index
@player_statistics = paginate(player_statistics)
end
def show_for_reservation_and_player
- @player_statistics = paginate(player_statistics.where("reservation_players.steam_uid = ? AND reservation_players.reservation_id = ?", params[:steam_uid].to_s, params[:reservation_id].to_i))
+ @player_statistics = paginate(player_statistics.joins(:reservation_player).where("reservation_players.steam_uid = ? AND reservation_players.reservation_id = ?", params[:steam_uid].to_s, params[:reservation_id].to_i))
render :index
end
def show_for_reservation
- @player_statistics = paginate(player_statistics.where("reservation_players.reservation_id = ?", params[:reservation_id].to_i))
+ @player_statistics = paginate(player_statistics.joins(:reservation_player).where("reservation_players.reservation_id = ?", params[:reservation_id].to_i))
render :index
end
def show_for_player
- @player_statistics = paginate(player_statistics.where("reservation_players.steam_uid = ?", params[:steam_uid].to_s))
+ @player_statistics = paginate(player_statistics.joins(:reservation_player).where("reservation_players.steam_uid = ?", params[:steam_uid].to_s))
render :index
end
def show_for_server
- @player_statistics = paginate(player_statistics.where("servers.id = ?", params[:server_id].to_i))
+ @player_statistics = paginate(player_statistics.joins(:server).where('servers.id = ?', params[:server_id].to_i))
render :index
end
@@ -1,5 +1,4 @@
class ServerStatisticsController < ApplicationController
- before_filter :require_admin
def index
@server_statistics = paginate(server_statistics)
@@ -11,7 +10,7 @@ def show_for_reservation
end
def show_for_server
- @server_statistics = paginate(server_statistics.where("servers.id = ?", params[:server_id].to_i))
+ @server_statistics = paginate(server_statistics.where("server_id = ?", params[:server_id].to_i))
render :index
end
@@ -4,6 +4,10 @@ def donator?
@current_user_is_donator ||= current_user && current_user.donator?
end
+ def admin?
+ @current_user_is_admin ||= current_user && current_user.admin?
+ end
+
def used_free_server_count
Reservation.current.where(:server_id => Server.without_group).count
end
@@ -15,7 +15,8 @@
%th Server
%th Date
%th Player
- %th IP
+ - if admin?
+ %th IP
%th Ping
%th Loss
%th Minutes connected
@@ -31,7 +32,8 @@
- time = I18n.l(player_statistic.created_at, format: :short_with_dayname_and_seconds)
= link_to(time, show_reservation_statistic_path(:reservation_id => player_statistic.reservation.id), :class => "player_reservation_statistics")
%td= link_to(player_statistic.name, show_player_statistic_path(:steam_uid => player_statistic.reservation_player.steam_uid))
- %td= player_statistic.reservation_player.ip
+ - if admin?
+ %td= player_statistic.reservation_player.ip
%td= link_to player_statistic.ping, show_reservation_and_player_statistic_path(:reservation_id => player_statistic.reservation.id, :steam_uid => player_statistic.reservation_player.steam_uid)
%td= player_statistic.loss
%td= player_statistic.minutes_connected
@@ -4,8 +4,9 @@
- cache "server_info_#{server.id}_#{server_info.uptime.to_i}_#{admin}", expires_in: 1.minute do
%tr
%td
- = server.flag
- = server_info.server_name
+ = link_to show_server_player_statistic_path(:server_id => server.id) do
+ = server.flag
+ = server_info.server_name
%td= server_info.map_name
%td= "#{server_info.number_of_players} / #{server_info.max_players}"
%td= server_info.fps
@@ -23,6 +24,8 @@
%td N/A
- rescue
%tr
- %td= server.name
+ %td
+ = link_to show_server_player_statistic_path(:server_id => server.id) do
+ = server.name
%td{:colspan => 8}
N/A
View
@@ -1,3 +1,5 @@
User-Agent: *
Disallow: /pages/recent_reservations
Disallow: /recent-reservations
+Disallow: /player_statistics
+Disallow: /server_statistics

0 comments on commit 2d8bbf8

Please sign in to comment.