Skip to content

Commit

Permalink
sort
Browse files Browse the repository at this point in the history
  • Loading branch information
Akhil committed Jun 1, 2014
1 parent 9961672 commit 1431905
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/models/helper_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module HelperModel
def self.get_response user
response = {}
slack_time = 5.minutes
response['all_events'] = Event.where("open_till > ?", Time.zone.now + slack_time).collect { |event|
response['all_events'] = Event.where("open_till > ?", Time.zone.now + slack_time).order('total_bets desc').collect { |event|
{
'id' => event.id,
'name' => event.name,
Expand Down
9 changes: 8 additions & 1 deletion app/models/outcome.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@ class Outcome < ActiveRecord::Base
def recalculate_and_update_odds(outcome_id=nil, event_id=nil)
# a new bet has been placed on this order


total_odds = 0
Event.find(event_id.to_i).outcomes.each do |x|
total_odds += x.odds.to_i
end

Event.find(event_id.to_i).outcomes.each do |x|
x.odds_display_text = x.odds.to_s + ":" + (total_odds-x.odds.to_i).to_s
x.save
end
end

belongs_to :event
Expand Down

0 comments on commit 1431905

Please sign in to comment.