eargollo / soccer

0 stars 0 forks source link

Refactor to a Rails idiomatic approach #1

Closed eargollo closed 10 months ago

eargollo commented 10 months ago

Add some tests and refactor https://github.com/eargollo/soccer/blob/main/app/models/standing.rb#L4

Add scope for finished and make the win and losses computation at the matches model. Something around the lines:

 wins = team.home_matches.won_by_home.count + team.away_matches.won_by_away.count
 losses = team.home_matches.won_by_away.count + team.away_matches.won_by_home.count
 draw = team.home_matches.count + team.away_matches.draw.count

Put business logic into the Model.

eargollo commented 10 months ago

Solved by #2