Class: RailsInformant::Api::ErrorsController
- Inherits:
-
BaseController
- Object
- ActionController::API
- BaseController
- RailsInformant::Api::ErrorsController
- Defined in:
- app/controllers/rails_informant/api/errors_controller.rb
Instance Method Summary collapse
- #destroy ⇒ Object
- #duplicate ⇒ Object
- #fix_pending ⇒ Object
- #index ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#destroy ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'app/controllers/rails_informant/api/errors_controller.rb', line 40 def destroy if ErrorGroup.exists?(duplicate_of_id: @error_group.id) render json: { error: "Cannot delete: other errors reference this as a duplicate target" }, status: :unprocessable_entity else @error_group.destroy! head :no_content end end |
#duplicate ⇒ Object
60 61 62 63 |
# File 'app/controllers/rails_informant/api/errors_controller.rb', line 60 def duplicate @error_group.mark_as_duplicate_of! params[:duplicate_of_id] render json: @error_group.as_json(only: ErrorGroup::API_DETAIL_FIELDS) end |
#fix_pending ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'app/controllers/rails_informant/api/errors_controller.rb', line 50 def fix_pending permitted = params.permit(:fix_sha, :original_sha, :fix_pr_url) @error_group.mark_as_fix_pending!( fix_sha: permitted[:fix_sha], original_sha: permitted[:original_sha], fix_pr_url: permitted[:fix_pr_url] ) render json: @error_group.as_json(only: ErrorGroup::API_DETAIL_FIELDS) end |
#index ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/rails_informant/api/errors_controller.rb', line 6 def index groups = params[:status] == "duplicate" ? ErrorGroup.all : ErrorGroup.active groups = groups .by_controller_action(params[:controller_action]) .by_error_class(params[:error_class]) .by_job_class(params[:job_class]) .by_severity(params[:severity]) .by_status(params[:status]) .search(params[:q]) .since(params[:since] && parse_time(params[:since])) .before(params[:until] && parse_time(params[:until])) .order(last_seen_at: :desc) render json: paginate(groups, only: ErrorGroup::API_FIELDS) end |
#show ⇒ Object
22 23 24 25 26 27 |
# File 'app/controllers/rails_informant/api/errors_controller.rb', line 22 def show occurrences = @error_group.occurrences.order(created_at: :desc).limit(10) render json: @error_group.as_json(only: ErrorGroup::API_DETAIL_FIELDS).merge( recent_occurrences: occurrences.as_json(only: Occurrence::API_FIELDS) ) end |
#update ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'app/controllers/rails_informant/api/errors_controller.rb', line 29 def update permitted = params.permit(:status, :notes) updates = {} updates[:status] = permitted[:status] if permitted[:status] updates[:notes] = permitted[:notes] if permitted.key?(:notes) @error_group.update!(updates) render json: @error_group.as_json(only: ErrorGroup::API_DETAIL_FIELDS) end |