Class: ReferenceEventsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- ReferenceEventsController
- Includes:
- ApplicationHelper, TimeHelper
- Defined in:
- app/controllers/reference_events_controller.rb
Instance Method Summary collapse
Methods included from TimeHelper
#cron_with_zone, #destructure_seconds
Methods included from AuthentificationHelper
#accessible_company_ids_from_tenant_and_user, #application_mode_from_hostname, #current_company_id_from_accessible_company_ids, #current_tenant_from_user, #current_user_and_locale_from_token
Instance Method Details
#index ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/controllers/reference_events_controller.rb', line 17 def index query = params[:query] || '' order = params[:order] || 'desc' order_by = params[:orderBy] || 'created_at' limit = params[:limit] || 10 offset = params[:offset] || 0 reference_events = current_company.reference_events.where( slug: EventNotificationConfiguration::NOTIFIABLE_EVENT_SLUGS ) data, = fetch_records( records: reference_events, order_by: order_by, order: order, query: query, limit: limit, offset: offset ).values_at(:data, :metadata) data = data.as_json( methods: [ 'name', 'description', 'occurence_description', 'status', 'event_notification_configuration_id' ] ) render json: { data: data, metadata: } end |
#show ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'app/controllers/reference_events_controller.rb', line 53 def show reference_event = current_company .reference_events .includes(:tags) .find(params[:id]) data = reference_event.as_json( methods: [ 'name', 'description', 'reference_url', 'reference_name', 'occurence_description', 'status', 'event_notification_configuration_id', 'last_deliveries' ], include: [ 'tags' ] ) render json: { data: data } end |