Class: SportDb::Model::Play

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/sportdb/play/models/play.rb

Instance Method Summary collapse

Instance Method Details

#complete_rankingsObject

todo/fix: can it be done w/ a has_many macro and a condition?



42
43
44
45
46
# File 'lib/sportdb/play/models/play.rb', line 42

def complete_rankings  # fix rename to points and remove points column from play table??
  ## nb: removed .all() - check if still working; should - but never know
  recs = Point.where( pool_id: pool_id, user_id: user_id ).joins( :round ).order('rounds.pos')
  recs
end

#export?Boolean

Returns:

  • (Boolean)


48
49
50
51
52
53
# File 'lib/sportdb/play/models/play.rb', line 48

def export?
  # check if user entered some data
  # - do NOT export nil records (all teams blank)
  
  (team1_id.blank? && team2_id.blank? && team3_id.blank?)==false
end

#job_done!Object



19
# File 'lib/sportdb/play/models/play.rb', line 19

def job_done!()      @job_running = false;  end

#job_running!Object



18
# File 'lib/sportdb/play/models/play.rb', line 18

def job_running!()   @job_running = true;   end

#job_running?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/sportdb/play/models/play.rb', line 21

def job_running?
  (@job_running ||= false) == true
end

#public?Boolean

Returns:

  • (Boolean)


25
26
27
28
29
30
31
# File 'lib/sportdb/play/models/play.rb', line 25

def public?
  return true if pool.public?

  # team1, team2 public after kickoff of event
  ## use past?
  Time.now.utc > pool.event.start_at.utc
end

#tipsObject

todo/fix: can it be done w/ a has_many macro and a condition?



35
36
37
38
39
# File 'lib/sportdb/play/models/play.rb', line 35

def tips
  ## nb: removed .all() - check if still working; should - but never know
  recs = Tip.where( pool_id: pool_id, user_id: user_id )
  recs
end