balloosnafoo / no-kicker

Capstone project proposal for final two weeks of the App Academy curriculum.
0 stars 0 forks source link

Wins / Losses #3

Open chf2 opened 9 years ago

chf2 commented 9 years ago

I think you have a couple options for wins / losses. On the one hand, you could increment wins and losses on the teams after the results of a week are in. If you do this, I'd set a default at zero for clarity.

A potentially better solution would be to have a schedule table, with team_1_id, team_2_id, week, and winning_team_id (for starters), and calculate wins and losses based on analysis of the join table. This also adds in a schedule which feels kind of core to the functionality.

balloosnafoo commented 9 years ago

I'm going to have to ask you more about implementing this the second way, but for now I at least added a table to the schema doc for matchups, because you're right... I definitely need that.

chf2 commented 9 years ago

OK sure, let's take a few minutes tomorrow to go over it

balloosnafoo commented 9 years ago

I started trying to implement the schedule this way and I am having one problem in particular. I'm not sure how to get matchups without defining two associations (one though team_1_id and the other through team_2_id).

chf2 commented 9 years ago

I think one possible solution is to define a custom association -- something like a model method on team #matchups that returns Team.where(id: Schedule.where("team_id_1 = ? OR team_id_2 = ?", id, id) (maybe break that up). Does that make sense / would it solve the issue?

You can also define "home_games" and "away_games" associations and then just make a method that combines the two results

balloosnafoo commented 9 years ago

I tried the second way and I am having some trouble getting the League's has_many :matchups to work. It seems like because I am getting an array back instead of an association.