Class: Api::V1::MeasurementsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/api/v1/measurements_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#after_sign_in_path_for, #api_authenticate!, #authenticated_via_token?, #current_project, #expire_revision!, #followed_projects, #no_cache, #oauth_authorize!, #read_revision, #require_login, #return_or_cache_revision!, #revision, #token_authenticate!, #unfurling?, #with_current_project

Methods included from UrlHelper

#feature_path, #link_to_project_feature

Instance Method Details

#indexObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/api/v1/measurements_controller.rb', line 16

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