Sha256: 691afa98e74babcc85432ff972cc62c389b309edff296e006c1746cd5e165eaa

Contents?: true

Size: 879 Bytes

Versions: 3

Compression:

Stored size: 879 Bytes

Contents

# encoding: utf-8

module SportDbAdmin

class GamesController < SportDbAdminController

  # GET /games
  def index
    # find next upcoming games
    limit = params[:limit] || '50'
    
    @games = Game.where( 'play_at > ?', Time.now ).order( 'play_at').limit(limit)
    @show_upcoming = true
  end
  
  # GET /games/past
  def past
    limit = params[:limit] || '50'
    
    if params[:null].present?   # e.g. use ?null=t
      ## find all past games w/ missing score
      @games = Game.where( 'play_at < ?', Time.now ).
                    where( 'score1 is null or score2 is null').
                    order( 'play_at desc').limit(limit)
    else
      @games = Game.where( 'play_at < ?', Time.now ).order( 'play_at desc').limit(limit)
    end
    
    @show_upcoming = false
    
    render :action => 'index'
  end

end # class GamesController

end # module SportDbAdmin

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sportdb-admin-0.3.0 app/controllers/sport_db_admin/games_controller.rb
sportdb-admin-0.2.0 app/controllers/sport_db_admin/games_controller.rb
sportdb-admin-0.1.1 app/controllers/sport_db_admin/games_controller.rb