Skip to content

Instantly share code, notes, and snippets.

@ncdc
Created January 13, 2012 20:10
Show Gist options
  • Save ncdc/1608450 to your computer and use it in GitHub Desktop.
Save ncdc/1608450 to your computer and use it in GitHub Desktop.
class RunsController < ApplicationController
# GET /runs
# GET /runs.json
def index
# start with all runs
@runs = Run.where('')
@since = params[:since]
@runs = @runs.since(@since.to_i.days.ago) if params[:since]
@passed = params[:passed] || ""
@runs = @runs.where(:passed => (params[:passed] == 'true')) unless params[:passed].blank?
@feature_file = params[:feature_file] || ""
@runs = @runs.includes(:feature_file).where(FeatureFile.arel_table[:name].matches("%#{params[:feature_file]}%")) if params[:feature_file]
@count = @runs.count
@offset = params[:offset] || 0
@runs = @runs.limit(100).offset(@offset).reverse_order
respond_to do |format|
format.html # index.html.erb
format.json { render :json => @runs }
format.js
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment