Sha256: 8e5f6f5d62d27aaa256af44de1e148bbf5f7c0f9dd83096e85190b45c7034d0b

Contents?: true

Size: 870 Bytes

Versions: 6

Compression:

Stored size: 870 Bytes

Contents

module Api
  module V1
    class MeasurementsController < ApplicationController
      before_filter :api_authenticate!
      skip_before_filter :verify_authenticity_token

      rescue_from ActiveRecord::RecordNotFound do
        head 404
      end

      rescue_from KeyError do |e|
        render json: { error: e.message }, status: 422
      end

      def index
        name = params.fetch :name
        start_time = params.fetch :start
        end_time = params.fetch :end
        measurements = Measurement.named(name).taken_between(start_time, end_time)

        if slugs = params[:project]
          slugs = slugs.split(",") if slugs.is_a?(String)
          projects = Project.where(slug: slugs)
          measurements = measurements.where(subject: projects)
        end

        render json: MeasurementsPresenter.new(measurements)
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
houston-core-0.8.0.pre app/controllers/api/v1/measurements_controller.rb
houston-core-0.7.0 app/controllers/api/v1/measurements_controller.rb
houston-core-0.7.0.beta4 app/controllers/api/v1/measurements_controller.rb
houston-core-0.7.0.beta3 app/controllers/api/v1/measurements_controller.rb
houston-core-0.7.0.beta2 app/controllers/api/v1/measurements_controller.rb
houston-core-0.7.0.beta app/controllers/api/v1/measurements_controller.rb