Prev | Current Page 101 | Next

David Berube

"Practical Reporting with Ruby and Rails"

connect( SEL_CONFIGURE ) do
update_display
end
@main_window.show( PLACEMENT_SCREEN )
end
def update_display
game_id_to_analyze = @game_combobox.getItemData(@game_combobox.currentItem)
player = Player.find(@player_combobox.getItemData(
@player_combobox.currentItem))
bar_chart = Gruff::Bar.new("#{@graph_picture_viewer.width}x" <<
"#{@graph_picture_viewer.height}")
bar_chart.legend_font_size = 12
total_games = Play.count(:conditions=>['game_id = ? AND ' <<
'player_id = ?',
game_id_to_analyze, player.id]
).to_f || 0
total_wins = Play.count(:conditions=>['game_id = ? AND ' <<
'player_id = ? AND won=1',
game_id_to_analyze, player.id]
).to_f || 0
bar_chart.title = "#{player.name} (#{'%i' %
(total_games==0 ? '0' :
(total_wins/total_games * 100))
}% won)"
bar_chart.minimum_value = 0
bar_chart.maximum_value = 110
sql = "SELECT event, AVG(time) as average_time
FROM events AS e
INNER JOIN
plays AS p
ON e.play_id=p.id
WHERE p.game_id='#{game_id_to_analyze}'
AND
p.player_id='#{player.id}'
GROUP BY e.


Pages:
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113