Sha256: 0468a880d6599e20667d9d50a00b1d8fe23b82d09031c0c7fefa9d7ba7850f18

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

module Orchestrator
    module Api
        class LogsController < ApiController
            respond_to :json
            before_action :doorkeeper_authorize!
            before_action :check_admin


            # deal with live reload   filter
            @@elastic ||= Elastic.new(::Orchestrator::AccessLog)


            def index
                query = @@elastic.query(params)
                query.sort = [{
                    created_at: "desc"
                }]

                # Filter systems via user_id
                if params.has_key? :user_id
                    user_id = params.permit(:user_id)[:user_id]
                    query.filter({
                        user_id: [user_id]
                    })
                end

                results = @@elastic.search(query) do |entry|
                    entry.as_json.tap do |json|
                        json[:systems] = ControlSystem.find_by_id(json[:systems]).as_json(only: [:id, :name]) || []
                    end
                end
                respond_with results
            end
        end
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
orchestrator-1.0.3 app/controllers/orchestrator/api/logs_controller.rb