| Fixes #23 by updating array syntax for rails4 - warvox - VoIP based wardialing … | |
| Log | |
| Files | |
| Refs | |
| README | |
| --- | |
| commit 52add4388c07da3d4eedcd10ba3df9623b2457aa | |
| parent f6291b823e9c2d5d2382765ec292183101c69e2e | |
| Author: HD Moore <[email protected]> | |
| Date: Mon, 27 Oct 2014 00:13:05 -0500 | |
| Fixes #23 by updating array syntax for rails4 | |
| Diffstat: | |
| M Gemfile | 1 + | |
| M app/assets/stylesheets/application… | 2 +- | |
| M app/models/call.rb | 43 +++++++++++++++++------------… | |
| A app/views/application/_nav.html.erb | 67 +++++++++++++++++++++++++++++… | |
| M app/views/shared/graphs/_lines_by_… | 2 +- | |
| 5 files changed, 93 insertions(+), 22 deletions(-) | |
| --- | |
| diff --git a/Gemfile b/Gemfile | |
| @@ -6,6 +6,7 @@ gem 'pg', '>=0.17' | |
| gem 'jquery-rails', '>= 3.1.2' | |
| gem 'jquery-datatables-rails', '>= 2.2.3' | |
| +#gem 'postgres_ext', :git => 'git://github.com/dockyard/postgres_ext.git' | |
| gem 'kissfft' | |
| gem 'rex', '~> 2.0.3' | |
| diff --git a/app/assets/stylesheets/application.css.scss.erb b/app/assets/style… | |
| @@ -300,7 +300,7 @@ a .project-title, a:visited .project-title { | |
| } | |
| .fwd_match_span { | |
| - width: 100px; | |
| + width: 150px; | |
| padding-left: 20px; | |
| padding-right: 20px; | |
| padding-bottom: 5px; | |
| diff --git a/app/models/call.rb b/app/models/call.rb | |
| @@ -19,7 +19,7 @@ class Call < ActiveRecord::Base | |
| # "AND (( icount(\'{#{fprint.map{|x| x.to_s}.join(",")}}\'::int[] & cal… | |
| self.find_by_sql([ | |
| 'SELECT calls.*, ' + | |
| - " (( icount(?::int[] & calls.fprint::int[]) / icount(?::int[])::float )… | |
| + " (( icount(ARRAY[?]::int[] & calls.fprint::int[]) / icount(ARRAY[?]::i… | |
| 'FROM calls ' + | |
| 'WHERE icount(calls.fprint) > 0 AND ' + | |
| "calls.job_id = ? AND " + | |
| @@ -37,43 +37,46 @@ class Call < ActiveRecord::Base | |
| # "AND (( icount(\'{#{fprint.map{|x| x.to_s}.join(",")}}\'::int[] & cal… | |
| self.find_by_sql([ | |
| 'SELECT calls.*, ' + | |
| - " (( icount(?::int[] & calls.fprint::int[]) / icount(?::int[])::float )… | |
| + " (( icount(ARRAY[?]::int[] & calls.fprint::int[]) / icount(ARRAY[?]::i… | |
| 'FROM calls ' + | |
| 'WHERE icount(calls.fprint) > 0 AND ' + | |
| "calls.id != ? " + | |
| 'ORDER BY matchscore DESC', | |
| - fprint_map, | |
| - fprint_map, | |
| + fprint, | |
| + fprint, | |
| self.id | |
| ]) | |
| end | |
| - def fprint_map | |
| - @fprint_map ||= "{" + fprint.map{|x| x.to_s}.join(",") + "}" | |
| - end | |
| - | |
| after_save :update_linked_line | |
| def paginate_matches(scope, min_match, page, per_page) | |
| - scope_limit = "" | |
| + match_sql = | |
| + 'SELECT calls.*, ' + | |
| + " (( icount(ARRAY[?]::int[] & calls.fprint::int[]) / icount(ARRAY[?]::i… | |
| + 'FROM calls ' + | |
| + 'WHERE icount(calls.fprint) > 0 AND ' | |
| + args = [fprint, fprint] | |
| + | |
| case scope | |
| when 'job' | |
| - scope_limit = "calls.job_id = \'#{job_id.to_i}\' AND " | |
| + match_sql << " calls.job_id = ? AND " | |
| + args << job.id.to_i | |
| when 'project' | |
| - scope_limit = "calls.project_id = \'#{project_id.to_i}\' AND " | |
| + match_sql << " calls.project_id = ? AND " | |
| + args << project_id.to_i | |
| end | |
| - query = | |
| - 'SELECT calls.*, ' + | |
| - " (( icount(\'{#{fprint_map}}\'::int[] & calls.fprint::int[]) / icount(… | |
| - 'FROM calls ' + | |
| - 'WHERE icount(calls.fprint) > 0 AND ' + | |
| - scope_limit + | |
| - "calls.id != \'#{id}\' " + | |
| - "AND (( icount(\'#{fprint_map}\'::int[] & calls.fprint::int[]) / icount(… | |
| - 'ORDER BY matchscore DESC' | |
| + match_sql << "calls.id != ? " | |
| + args << self.id | |
| + | |
| + match_sql << " AND (( icount(ARRAY[?]::int[] & calls.fprint::int[]) / icou… | |
| + args << fprint | |
| + args << fprint | |
| + args << min_match.to_f | |
| + query = [match_sql, *args] | |
| Call.paginate_by_sql(query, :page => page, :per_page => per_page) | |
| end | |
| diff --git a/app/views/application/_nav.html.erb b/app/views/application/_nav.h… | |
| @@ -0,0 +1,67 @@ | |
| + | |
| +<nav class="navbar navbar-default navbar-fixed-top" role="navigation"> | |
| + <div class="container-fluid"> | |
| + <!-- Brand and toggle get grouped for better mobile display --> | |
| + <div class="navbar-header"> | |
| + <button type="button" class="navbar-toggle collapsed" data-toggle="colla… | |
| + <span class="sr-only">Toggle navigation</span> | |
| + <span class="fa fa-bar"></span> | |
| + <span class="fa fa-bar"></span> | |
| + <span class="fa fa-bar"></span> | |
| + </button> | |
| + <a class="navbar-brand" href="/"><img src="/assets/logo_light.png" borde… | |
| + </div> | |
| + | |
| + <div class="collapse navbar-collapse navbar-ex1-collapse"> | |
| + <ul class="nav navbar-nav navbar-right"> | |
| + | |
| + <% if @project and @project.id %> | |
| + <li> | |
| + <%= link_to( | |
| + raw( | |
| + '<i class="fa fa-chevron-left icon-white"></i> ' + | |
| + h(truncate(@project.name, :length => 20)) + | |
| + ' <i class="fa fa-chevron-right icon-white"></i>'), project_path… | |
| + </li> | |
| + <li><a href="<%= results_path(@project) %>">Scans</a></li> | |
| + <li><a href="<%= analyze_path(@project) %>">Analysis</a></li> | |
| + <% end %> | |
| + | |
| + <li><a href="<%= jobs_path %>">Jobs</a></li> | |
| + | |
| + <li class="dropdown"> | |
| + <a href="#" class="dropdown-toggle" data-toggle="dropdown">Projects … | |
| + <ul class="dropdown-menu" role="menu"> | |
| + | |
| + <% if Project.count > 0 %> | |
| + <li><a href="<%= projects_path %>"><i class="fa fa-list"></i> Brow… | |
| + <% end %> | |
| + | |
| + <li><a href="<%= new_project_path %>"><i class="fa fa-plus"></i> Cre… | |
| + | |
| + <% if Project.count > 0 %> | |
| + <li class="divider"></li> | |
| + <li> Recent Projects</li> | |
| + <% Project.order('ID DESC').limit(5).each do |project| %> | |
| + <li><a href="<%= project_path(project)%>"><i class="fa fa-chevro… | |
| + <% end %> | |
| + <% end %> | |
| + </ul> | |
| + </li> | |
| + | |
| + <li class="dropdown"> | |
| + <a href="#" class="dropdown-toggle" data-toggle="dropdown">Admin <sp… | |
| + <ul class="dropdown-menu" role="menu"> | |
| + <li><a href="<%= user_path(current_user) %>"><i class="fa fa-user"><… | |
| + <li><a href="<%= providers_path%>"><i class="fa fa-globe"></i> Provi… | |
| + <!-- <li><a href="<%= settings_path%>"><i class="fa fa-wrench"></i> … | |
| + <li><a href="<%= about_path%>"><i class="fa fa-info-circle"></i> Abo… | |
| + </ul> | |
| + </li> | |
| + | |
| + <li><a href="<%= logout_path %>"><div class="help-icon"><i class="fa f… | |
| + <li><a href="<%= check_path %>"<div class="help-icon"><i class="fa fa-… | |
| + </ul> | |
| + </div><!-- /.navbar-collapse --> | |
| + </div><!-- /.container-fluid --> | |
| +</nav> | |
| diff --git a/app/views/shared/graphs/_lines_by_type.html.erb b/app/views/shared… | |
| @@ -18,7 +18,7 @@ end | |
| chart: { | |
| renderTo: '<%= graph_id %>', | |
| type: 'bar', | |
| - height: 150 | |
| + height: 250 | |
| }, | |
| title: { | |
| text: 'Line Types' |