Sha256: 0af1a0fda6b9bae292bfe33438aaf88781b822bf0f4b8a8a553d7dcfa9f51707
Contents?: true
Size: 1.5 KB
Versions: 11
Compression:
Stored size: 1.5 KB
Contents
module Adhoq class ExecutionsController < Adhoq::ApplicationController def show @execution = current_query.executions.where(id: params[:id], report_format: params[:format]).first! respond_report(@execution.report) end def create async_execution? ? asynced_create : synced_create end private def synced_create @execution = current_query.execute!(params[:execution][:report_format], query_parameters) if @execution.report.on_the_fly? respond_report(@execution.report) else redirect_to current_query end end def asynced_create Adhoq::ExecuteJob.perform_later(current_query, params[:execution][:report_format], query_parameters) redirect_to current_query end def current_query @query ||= Adhoq::Query.find(params[:query_id]) end def respond_report(report) if Adhoq.current_storage.direct_download? redirect_to report.data_url else send_data report.data, type: report.mime_type, filename: report.name, disposition: 'attachment' end end def async_execution? Adhoq.config.async_execution? && !Adhoq.current_storage.is_a?(Adhoq::Storage::OnTheFly) end def query_parameters if params[:parameters] if params[:parameters].kind_of?(Hash) params[:parameters] else # for after Rails5 params[:parameters].to_unsafe_hash end else HashWithIndifferentAccess.new end end end end
Version data entries
11 entries across 11 versions & 1 rubygems