Schema overhaul for job work - warvox - VoIP based wardialing tool, forked from rapid7/warvox.
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
---
(DIR) commit 74be216401da43b3f2234fdcf38c2a07da7c9108
(DIR) parent 8fbc16b98fa9c135884a2c644af7ffadbe6a2752
(HTM) Author: HD Moore <hd_moore@rapid7.com>
Date: Mon, 31 Dec 2012 13:04:38 -0600
Schema overhaul for job work
Diffstat:
A app/models/call.rb | 37 +++++++++++++++++++++++++++++++
A app/models/call_medium.rb | 3 +++
A app/models/job.rb | 4 ++++
A app/models/line.rb | 3 +++
A app/models/line_attribute.rb | 3 +++
M app/models/project.rb | 2 ++
A app/models/signature.rb | 4 ++++
A app/models/signature_fp.rb | 4 ++++
8 files changed, 60 insertions(+), 0 deletions(-)
---
(DIR) diff --git a/app/models/call.rb b/app/models/call.rb
@@ -0,0 +1,37 @@
+class Call < ActiveRecord::Base
+ belongs_to :project
+ belongs_to :provider
+ belongs_to :job
+ has_one :call_medium, :dependent => :delete
+
+ has_many :matches, :class_name => 'Call', :finder_sql => proc {
+ 'SELECT calls.*, ' +
+ " (( icount(\'{#{fprint.map{|x| x.to_s}.join(",")}}\'::int[] & calls.fprint::int[]) / icount(\'{#{fprint.map{|x| x.to_s}.join(",")}}'::int[])::float ) * 100.0 ) AS matchscore " +
+ 'FROM calls ' +
+ 'WHERE icount(calls.fprint) > 0 AND ' +
+ "calls.job_id = \'#{job_id}\' AND " +
+ "calls.id != \'#{id}\' " +
+# "AND (( icount(\'{#{fprint.map{|x| x.to_s}.join(",")}}\'::int[] & calls.fprint::int[]) / icount(\'{#{fprint.map{|x| x.to_s}.join(",")}}'::int[])::float ) * 100.0 ) > 10.0 " +
+ 'ORDER BY matchscore DESC'
+ }
+
+ has_many :matches_all_jobs, :class_name => 'Call', :finder_sql => proc {
+ 'SELECT calls.*, ' +
+ " (( icount(\'{#{fprint.map{|x| x.to_s}.join(",")}}\'::int[] & calls.fprint::int[]) / icount(\'{#{fprint.map{|x| x.to_s}.join(",")}}\'::int[])::float ) * 100.0 ) AS matchscore " +
+ 'FROM calls ' +
+ 'WHERE icount(calls.fprint) > 0 AND ' +
+ "calls.id != \'#{id}\' " +
+# "AND (( icount(\'{#{fprint.map{|x| x.to_s}.join(",")}}\'::int[] & calls.fprint::int[]) / icount(\'{#{fprint.map{|x| x.to_s}.join(",")}}'::int[])::float ) * 100.0 ) > 10.0 " +
+ 'ORDER BY matchscore DESC'
+ }
+
+
+ def media
+ CallMedium.find_or_create_by_call_id(self[:id])
+ end
+
+ def media_fields
+ CallMedium.columns_hash.keys.reject{|x| x =~ /^id|_id$/}
+ end
+
+end
(DIR) diff --git a/app/models/call_medium.rb b/app/models/call_medium.rb
@@ -0,0 +1,3 @@
+class CallMedium < ActiveRecord::Base
+ belongs_to :call
+end
(DIR) diff --git a/app/models/job.rb b/app/models/job.rb
@@ -0,0 +1,4 @@
+class Job < ActiveRecord::Base
+ has_many :calls
+ belongs_to :project
+end
(DIR) diff --git a/app/models/line.rb b/app/models/line.rb
@@ -0,0 +1,3 @@
+class Line < ActiveRecord::Base
+ has_many :line_attributes
+end
(DIR) diff --git a/app/models/line_attribute.rb b/app/models/line_attribute.rb
@@ -0,0 +1,3 @@
+class LineAttribute < ActiveRecord::Base
+ belongs_to :line
+end
(DIR) diff --git a/app/models/project.rb b/app/models/project.rb
@@ -2,4 +2,6 @@ class Project < ActiveRecord::Base
validates_presence_of :name
attr_accessible :name, :description, :included, :excluded
+
+ has_many :lines, :calls, :jobs
end
(DIR) diff --git a/app/models/signature.rb b/app/models/signature.rb
@@ -0,0 +1,4 @@
+class Signature < ActiveRecord::Base
+ has_many :signature_fps
+
+end
(DIR) diff --git a/app/models/signature_fp.rb b/app/models/signature_fp.rb
@@ -0,0 +1,4 @@
+class SignatureFp < ActiveRecord::Base
+ belongs_to :signature
+
+end