Sha256: 307459743553644d8c11fa2052dce95a7b32b472e01a0bc7da3903d566a607e6
Contents?: true
Size: 917 Bytes
Versions: 9
Compression:
Stored size: 917 Bytes
Contents
module Api module V1 class MeasurementsController < ApplicationController before_action :api_authenticate! skip_before_action :verify_authenticity_token skip_around_action :with_current_project 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
9 entries across 9 versions & 1 rubygems