Skip to content

Instantly share code, notes, and snippets.

@jsmestad
Created April 5, 2009 05:02
Show Gist options
  • Select an option

  • Save jsmestad/90374 to your computer and use it in GitHub Desktop.

Select an option

Save jsmestad/90374 to your computer and use it in GitHub Desktop.
#players = select distinct(player) from actions;
players = repository(:default).adapter.query('select distinct(player) from actions')
@players = []
players.each do |name|
player = {}
player["name"] = name
player["won"] = Action.sum(:amount, :conditions => ["player = '#{name}' and amount != 'NULL' and (type = 'award' or type = 'return')"])
player["lost"] = Action.sum(:amount, :conditions => ["player = '#{name}' and amount != 'NULL' and type != 'award' and type != 'return'"])
@players << player
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment