Class: RailsInformant::Api::OccurrencesController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/rails_informant/api/occurrences_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



4
5
6
7
8
9
10
11
# File 'app/controllers/rails_informant/api/occurrences_controller.rb', line 4

def index
  occurrences = Occurrence.order(created_at: :desc)
  occurrences = occurrences.where(error_group_id: params[:error_group_id]) if params[:error_group_id]
  occurrences = occurrences.where(created_at: parse_time(params[:since])..) if params[:since]
  occurrences = occurrences.where(created_at: ..parse_time(params[:until])) if params[:until]

  render json: paginate(occurrences, only: Occurrence::API_FIELDS)
end