Slightly more functional rails4 code - warvox - VoIP based wardialing tool, forked from rapid7/warvox.
DIR Log
DIR Files
DIR Refs
DIR README
---
DIR commit 24fce918407bce8c43734e120a1f4aa4e1343656
DIR parent 9daf341c542e2c723c6db741e469251e30768597
HTML Author: HD Moore <hd_moore@rapid7.com>
Date: Sat, 25 Oct 2014 12:18:33 -0500
Slightly more functional rails4 code
Diffstat:
M app/controllers/analyze_controller… | 2 +-
M app/models/job.rb | 6 +++---
M app/views/jobs/new_analyze.html.erb | 2 +-
M lib/warvox/jobs/analysis.rb | 4 ++--
4 files changed, 7 insertions(+), 7 deletions(-)
---
DIR diff --git a/app/controllers/analyze_controller.rb b/app/controllers/analyze_controller.rb
@@ -81,7 +81,7 @@ class AnalyzeController < ApplicationController
def index
@shown = params[:show]
- ltypes = Line.find( :all, :select => 'DISTINCT line_type', :conditions => ["project_id = ?", @project.id] ).map{|r| r.line_type}
+ ltypes = Line.select('DISTINCT line_type', :conditions => ["project_id = ?", @project.id] ).map{|r| r.line_type}
res_types = {}
ltypes.each do |k|
DIR diff --git a/app/models/job.rb b/app/models/job.rb
@@ -82,14 +82,14 @@ class Job < ActiveRecord::Base
validates_with JobValidator
def stop
- self.class.update_all({ :status => 'cancelled'}, { :id => self.id })
+ self.class.where(id: self.id).update_all(status: 'cancelled')
end
def update_progress(pct)
if pct >= 100
- self.class.update_all({ :progress => pct, :completed_at => Time.now, :status => 'completed' }, { :id => self.id })
+ self.class.where(id: self.id).update_all(:progress => pct, :completed_at => Time.now, :status => 'completed')
else
- self.class.update_all({ :progress => pct }, { :id => self.id })
+ self.class.where(id: self.id).update_all(:progress => pct)
end
end
DIR diff --git a/app/views/jobs/new_analyze.html.erb b/app/views/jobs/new_analyze.html.erb
@@ -1,6 +1,6 @@
<h1 class='title'>Call Analysis</h1>
-<%= semantic_form_for(@job, :url => analyze_project_job_path(@project) ) do |f| %>
+<%= semantic_form_for(@job, :url => analyzer_job_path, :html => { :multipart => true, :method => :put }) do |f| %>
<% if @project %>
<%= f.input :project_id, :as => :hidden, :input_html => { :value => @project.id } %>
DIR diff --git a/lib/warvox/jobs/analysis.rb b/lib/warvox/jobs/analysis.rb
@@ -148,10 +148,10 @@ class Analysis < Base
def run_analyze_call(cid, jid)
- dr = Call.find(cid, :include => :job)
+ dr = Call.includes(:job).where(id: cid).first
dr.analysis_started_at = Time.now
dr.analysis_job_id = jid
- dr.save
+ dr.save!
WarVOX::Log.debug("Worker processing audio for #{dr.number}...")