Marnen Laibow-Koser wrote in post #965782:
> Please avoid top-posting.
>
> Cameron Caine wrote in post #965778:
>> Thanks this certainly helps.  Any reason in particular why you don't
>> recommend getting aggregates in the same query?
>
> I thought about that again after I posted it.  It's less easy to use
> ActiveRecord's abstraction layer, and you may be getting a lot of data
> you don't need if you pack everything into the one query.  But it's
> probably not as inadvisable as I had originally implied.
>

Do you know of any resource I could read up on returning aggregates 
along with the existing rows?  I've never seen that before is all.

>>
>> Things I need so far as is results like:
>>
>> Win Count
>> Loss Count
>> Draw Count
>> Win %
>> Home Wins %
>> Away Wins %
>> Scoring Average
>
> Yes?  And how are these calculated?

So far the win/loss is calculated from the field of 'home_score' and 
'away_score'
I could easily add an outcome integer column (0,1,2) to get an index on 
it.

so it could be like

class Game < AR::Base
  scope :win, where(:outcome => 0)
  @team.games.win
end

Not sure if I could chain a sum/average onto that. Will have to look 
into it.

>
>>
>> The list goes on and on and into nested models in the game:
>
> Best,
> --
> Marnen Laibow-Koser
> http://www.marnen.org
> [email protected]

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to