lib/rest-ftp-daemon/api/jobs.rb in rest-ftp-daemon-0.247.1 vs lib/rest-ftp-daemon/api/jobs.rb in rest-ftp-daemon-0.250.0

- old
+ new

@@ -1,28 +1,9 @@ -require "grape" - module RestFtpDaemon module API class Jobs < Grape::API - ### HELPERS - - helpers do - def logger - Root.logger - end - end - - - ### Common request logging - before do - log_info "HTTP #{request.request_method} #{request.fullpath}", params - end - - - ### READ ONE JOB - desc "Read job with ID" params do requires :id, type: String, desc: "ID of the Job to read" end get "/:id", requirements: { id: /.*/ } do @@ -45,13 +26,10 @@ present job, with: RestFtpDaemon::API::Entities::JobPresenter, type: "complete" end end - - ### READ ALL JOBS - desc "List all Jobs" get "/" do begin # Get jobs to display jobs = $queue.jobs @@ -65,13 +43,10 @@ present jobs, with: RestFtpDaemon::API::Entities::JobPresenter end end - - ### CREATE A JOB - desc "Create a new job" params do requires :source, type: String, desc: "Source file pattern" requires :target, type: String, desc: "Target remote path" optional :label, type: String, desc: "Descriptive label for this job" @@ -100,10 +75,10 @@ # And push it to the queue $queue.push job # Increment a counter - $queue.counter_inc :jobs_received + $stats.increment :jobs, :received rescue JSON::ParserError => exception log_error "JSON::ParserError: #{exception.message}" error!({error: :api_parse_error, message: exception.message}, 422)