Sha256: 4a77de636869e0363f7da26593f0790f711dd020e3e1d904dd41b801501b5f19

Contents?: true

Size: 842 Bytes

Versions: 18

Compression:

Stored size: 842 Bytes

Contents

module FieldTest
  class ExperimentsController < BaseController
    def index
      @active_experiments, @completed_experiments = FieldTest::Experiment.all.sort_by(&:id).partition { |e| e.active? }
    end

    def show
      @experiment = FieldTest::Experiment.find(params[:id])

      @per_page = 200
      @page = [1, params[:page].to_i].max
      offset = (@page - 1) * @per_page
      @memberships = @experiment.memberships.order(created_at: :desc).limit(@per_page).offset(offset).to_a

      @events =
        if FieldTest.events_supported?
          @experiment.events.where(field_test_membership_id: @memberships.map(&:id)).group(:field_test_membership_id, :name).count
        else
          {}
        end
    rescue FieldTest::ExperimentNotFound
      raise ActionController::RoutingError, "Experiment not found"
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
field_test-0.7.0 app/controllers/field_test/experiments_controller.rb
field_test-0.6.1 app/controllers/field_test/experiments_controller.rb
field_test-0.6.0 app/controllers/field_test/experiments_controller.rb
field_test-0.5.5 app/controllers/field_test/experiments_controller.rb
field_test-0.5.4 app/controllers/field_test/experiments_controller.rb
field_test-0.5.3 app/controllers/field_test/experiments_controller.rb
field_test-0.5.2 app/controllers/field_test/experiments_controller.rb
field_test-0.5.1 app/controllers/field_test/experiments_controller.rb
field_test-0.5.0 app/controllers/field_test/experiments_controller.rb
field_test-0.4.1 app/controllers/field_test/experiments_controller.rb
field_test-0.4.0 app/controllers/field_test/experiments_controller.rb
field_test-0.3.2 app/controllers/field_test/experiments_controller.rb
field_test-0.3.1 app/controllers/field_test/experiments_controller.rb
field_test-0.3.0 app/controllers/field_test/experiments_controller.rb
field_test-0.2.4 app/controllers/field_test/experiments_controller.rb
field_test-0.2.3 app/controllers/field_test/experiments_controller.rb
field_test-0.2.2 app/controllers/field_test/experiments_controller.rb
field_test-0.2.1 app/controllers/field_test/experiments_controller.rb