Matches - warvox - Unnamed repository; edit this file 'description' to name the repository. (DIR) Log (DIR) Files (DIR) Refs (DIR) README --- (DIR) commit edfaf614409017aa10ff9507ca8c4498a5827879 (DIR) parent 9dddb5e0d690140543cb3b3f2cde9afbb94bef55 (HTM) Author: HD Moore <hd_moore@rapid7.com> Date: Thu, 4 Aug 2011 18:49:06 +0000 Matches Diffstat: M web/app/models/dial_result.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+), 0 deletions(-) --- (DIR) diff --git a/web/app/models/dial_result.rb b/web/app/models/dial_result.rb @@ -1,4 +1,21 @@ class DialResult < ActiveRecord::Base belongs_to :provider belongs_to :dial_job + + + has_many :matches, :class_name => 'DialResult', :finder_sql => + 'SELECT dial_results.*, ' + + ' (( icount(\'#{fprint}\'::int[] & dial_results.fprint::int[]) / icount(\'#{fprint}\'::int[])::float ) * 100.0 ) AS matchscore ' + + 'FROM dial_results ' + + 'WHERE icount(dial_results.fprint) > 0 AND ' + + 'dial_results.dial_job_id = \'#{dial_job_id}\' ' + + 'ORDER BY matchscore DESC' + + has_many :matches_all_jobs, :class_name => 'DialResult', :finder_sql => + 'SELECT dial_results.*, ' + + ' (( icount(\'#{fprint}\'::int[] & dial_results.fprint::int[]) / icount(\'#{fprint}\'::int[])::float ) * 100.0 ) AS matchscore ' + + 'FROM dial_results ' + + 'WHERE icount(dial_results.fprint) > 0 ' + + 'ORDER BY matchscore DESC' + end