| Sync up recent work, merge up schemas - warvox - VoIP based wardialing tool, fo… | |
| Log | |
| Files | |
| Refs | |
| README | |
| --- | |
| commit ed69a4cfab7489d66d8c9946e8b7531d293e563c | |
| parent 08c1cd940e4cce5310d4d80dc68770d802eb7290 | |
| Author: HD Moore <[email protected]> | |
| Date: Sat, 12 Jan 2013 20:57:08 -0600 | |
| Sync up recent work, merge up schemas | |
| Diffstat: | |
| M Gemfile | 3 +-- | |
| M Gemfile.lock | 9 +++++++++ | |
| M app/assets/stylesheets/bootstrap_a… | 32 +++++++++++++++++++++++++++… | |
| M app/controllers/application_contro… | 5 ++++- | |
| M app/controllers/jobs_controller.rb | 7 +++++-- | |
| M app/controllers/projects_controlle… | 1 + | |
| M app/models/call.rb | 10 ++++++++++ | |
| M app/models/job.rb | 7 +++++++ | |
| M app/views/projects/show.html.erb | 104 ++++++++++++++++++++++++-----… | |
| M app/views/shared/graphs/_call_resu… | 7 ------- | |
| M app/views/shared/graphs/_lines_by_… | 5 ----- | |
| A app/views/shared/graphs/_sparkline… | 67 +++++++++++++++++++++++++++… | |
| M db/migrate/20121228171549_initial_… | 28 ++++++++++++++++++++++++++-- | |
| D db/migrate/20130106000000_add_inde… | 29 ---------------------------… | |
| A db/migrate/20130113004653_create_r… | 40 +++++++++++++++++++++++++++… | |
| M db/schema.rb | 21 ++++++++++++++++++--- | |
| M lib/warvox/jobs/analysis.rb | 2 +- | |
| 17 files changed, 301 insertions(+), 76 deletions(-) | |
| --- | |
| diff --git a/Gemfile b/Gemfile | |
| @@ -33,8 +33,7 @@ gem 'rails_bootstrap_navbar' | |
| gem 'less-rails-bootstrap' | |
| gem 'therubyracer' | |
| - | |
| -# gem "therubyracer", :group => :assets, :platform => :ruby | |
| +gem 'reportable', :git => '[email protected]:hmoore-r7/reportable.git', :require … | |
| gem 'will_paginate', '~> 3.0' | |
| gem 'will_paginate-bootstrap' | |
| diff --git a/Gemfile.lock b/Gemfile.lock | |
| @@ -6,6 +6,14 @@ GIT | |
| activerecord (~> 3.2.0) | |
| pg_array_parser (~> 0.0.8) | |
| +GIT | |
| + remote: [email protected]:hmoore-r7/reportable.git | |
| + revision: f8532eeb704c511bb75b5bd4fd9656243c9b118b | |
| + specs: | |
| + reportable (1.2.0) | |
| + activerecord (>= 3.0) | |
| + activesupport (>= 3.0.0) | |
| + | |
| GEM | |
| remote: http://rubygems.org/ | |
| specs: | |
| @@ -171,6 +179,7 @@ DEPENDENCIES | |
| rails (>= 3.2.11) | |
| rails-settings-cached | |
| rails_bootstrap_navbar | |
| + reportable! | |
| sass-rails (~> 3.2.3) | |
| therubyracer | |
| thin | |
| diff --git a/app/assets/stylesheets/bootstrap_and_overrides.css.less b/app/asse… | |
| @@ -39,6 +39,9 @@ | |
| @lightGray: #666666; | |
| @blue: #0197b8; | |
| +@darkOrange: #BB4607; | |
| +@lightOrange: #F8ECE6; | |
| + | |
| @linkColor: @blue; | |
| @linkColorHover: @darkGray; | |
| @@ -81,10 +84,39 @@ | |
| // End of DataTables | |
| + | |
| +.sparkline { | |
| + width: 100px; | |
| + height: 20px; | |
| +} | |
| + | |
| .call-detail { | |
| font-size: 10px; | |
| } | |
| +.project-header { | |
| + margin-bottom: 30px; | |
| + border-bottom: 1px solid #eeeeee; | |
| +} | |
| + | |
| +.stat-box { | |
| + padding: 10px; | |
| + | |
| + background-color: #eeeeee; | |
| + border: 1px solid #bbbbbb; | |
| + font-size: 18px; | |
| + font-weight: bold; | |
| + color: @darkGray; | |
| + width: 65px; | |
| + margin: auto auto; | |
| + text-align: center; | |
| +} | |
| + | |
| +.stat-subtitle { | |
| + text-align: center; | |
| + font-size: 12px; | |
| + margin-top: 1px; | |
| +} | |
| .fwd_match_span { | |
| width: 100px; | |
| diff --git a/app/controllers/application_controller.rb b/app/controllers/applic… | |
| @@ -1,10 +1,13 @@ | |
| class ApplicationController < ActionController::Base | |
| - helper :all | |
| protect_from_forgery | |
| + helper :all | |
| + | |
| helper_method :current_user_session, :current_user | |
| before_filter :require_user, :load_project | |
| add_breadcrumb :projects, :root_path | |
| + | |
| + | |
| private | |
| def current_user_session | |
| diff --git a/app/controllers/jobs_controller.rb b/app/controllers/jobs_controll… | |
| @@ -145,7 +145,7 @@ class JobsController < ApplicationController | |
| respond_to do |format| | |
| format.html | |
| format.xml { render :xml => @job } | |
| - end | |
| + end | |
| end | |
| def purge_calls | |
| @@ -158,7 +158,7 @@ class JobsController < ApplicationController | |
| def dialer | |
| @job = Job.new(params[:job]) | |
| - @job.created_by = current_user.login | |
| + @job.created_by = @current_user.login | |
| @job.task = 'dialer' | |
| @job.range.gsub!(/[^0-9X:,\n]/, '') | |
| @job.cid_mask.gsub!(/[^0-9X]/, '') if @job.cid_mask != "SELF" | |
| @@ -185,6 +185,7 @@ class JobsController < ApplicationController | |
| :task => 'analysis', :scope => 'job', :target_id => @j… | |
| :project_id => @project.id, :status => 'submitted' | |
| }) | |
| + @new.created_by = @current_user.login | |
| respond_to do |format| | |
| if @new.schedule | |
| flash[:notice] = 'Analysis job was successfull… | |
| @@ -215,6 +216,8 @@ class JobsController < ApplicationController | |
| }) | |
| end | |
| + @new.created_by = @current_user.login | |
| + | |
| respond_to do |format| | |
| if @new.schedule | |
| flash[:notice] = 'Analysis job was successfull… | |
| diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_… | |
| @@ -23,6 +23,7 @@ class ProjectsController < ApplicationController | |
| format.html # show.html.erb | |
| format.xml { render :xml => @project } | |
| end | |
| + | |
| end | |
| # GET /projects/new | |
| diff --git a/app/models/call.rb b/app/models/call.rb | |
| @@ -1,4 +1,14 @@ | |
| class Call < ActiveRecord::Base | |
| + | |
| + reportable :hourly, :aggregation => :count, :grouping => :hour, :live_… | |
| + reportable :daily, :aggregation => :count, :grouping => :day, :live_da… | |
| + reportable :weekly, :aggregation => :count, :grouping => :week, :live_… | |
| + reportable :monthly, :aggregation => :count, :grouping => :month, :liv… | |
| + reportable :analyzed_hourly, :aggregation => :count, :grouping => :hou… | |
| + reportable :analyzed_daily, :aggregation => :count, :grouping => :day,… | |
| + reportable :analyzed_weekly, :aggregation => :count, :grouping => :wee… | |
| + reportable :analyzed_monthly, :aggregation => :count, :grouping => :mo… | |
| + | |
| belongs_to :project | |
| belongs_to :provider | |
| belongs_to :job | |
| diff --git a/app/models/job.rb b/app/models/job.rb | |
| @@ -1,5 +1,10 @@ | |
| class Job < ActiveRecord::Base | |
| + reportable :hourly, :aggregation => :count, :grouping => :hour, :date_… | |
| + reportable :daily, :aggregation => :count, :grouping => :day, :date_co… | |
| + reportable :weeky, :aggregation => :count, :grouping => :week, :date_c… | |
| + reportable :monthly, :aggregation => :count, :grouping => :month, :dat… | |
| + | |
| class JobValidator < ActiveModel::Validator | |
| def validate(record) | |
| case record.task | |
| @@ -100,6 +105,8 @@ class Job < ActiveRecord::Base | |
| :seconds => self.seconds.to_i, | |
| :cid_mask => self.cid_mask | |
| }) | |
| + $stderr.puts self.inspect | |
| + | |
| return self.save | |
| when 'analysis' | |
| self.status = 'submitted' | |
| diff --git a/app/views/projects/show.html.erb b/app/views/projects/show.html.erb | |
| @@ -1,24 +1,80 @@ | |
| -<h1 class='title'>View Project</h1> | |
| -<p> | |
| - <b>Name:</b> | |
| - <%=h @project.name %> | |
| -</p> | |
| - | |
| -<p> | |
| - <b>Description:</b> | |
| - <%=h @project.description %> | |
| -</p> | |
| - | |
| -<p> | |
| - <b>Default Include:</b> | |
| - <%=h @project.included %> | |
| -</p> | |
| - | |
| -<p> | |
| - <b>Default Exclude:</b> | |
| - <%=h @project.excluded %> | |
| -</p> | |
| - | |
| - | |
| -<%= link_to 'Edit', edit_project_path(@project) %> | | |
| -<%= link_to 'Back', projects_path %> | |
| + | |
| + | |
| + | |
| +<div class="row-fluid"> | |
| + <div class="span12"> | |
| + <a class="btn btn-small pull-right" href="<%= edit_project_pat… | |
| + <h1 class='title'>Project <%= @project.name %></h1> | |
| + <p class='project-header'><%=h @project.description %></p> | |
| + </div> | |
| +</div> | |
| + | |
| + | |
| +<div class="row-fluid"> | |
| + <div class="span2"> | |
| + <div class="stat-box"> | |
| + <div><%= number_with_delimiter( @project.calls.count )… | |
| + <span class="stat-subtitle">Calls</span> | |
| + </div> | |
| + </div> | |
| + <div class="span2"> | |
| + <div class="stat-box"> | |
| + <div><%= number_with_delimiter( @project.calls.where(:… | |
| + <span class="stat-subtitle">Answered</span> | |
| + </div> | |
| + </div> | |
| + <div class="span2"> | |
| + <div class="stat-box"> | |
| + <div><%= number_with_delimiter( @project.calls.where('… | |
| + <span class="stat-subtitle">Analyzed</span> | |
| + </div> | |
| + </div> | |
| + | |
| + <div class="span2"> | |
| + <div class="stat-box"> | |
| + <div><%= number_with_delimiter( @project.calls.where(:… | |
| + <span class="stat-subtitle">Voice</span> | |
| + </div> | |
| + </div> | |
| + <div class="span2"> | |
| + <div class="stat-box"> | |
| + <div><%= number_with_delimiter( @project.calls.where(:… | |
| + <span class="stat-subtitle">Fax</span> | |
| + </div> | |
| + </div> | |
| + <div class="span2"> | |
| + <div class="stat-box"> | |
| + <div><%= number_with_delimiter( @project.calls.where(:… | |
| + <span class="stat-subtitle">Modem</span> | |
| + </div> | |
| + </div> | |
| +</div> | |
| + | |
| + | |
| + | |
| +<div class="row-fluid"> | |
| + <div class="span2"> | |
| + <%= render :partial => 'shared/graphs/sparkline', :locals => {… | |
| + Calls/Hour | |
| + </div> | |
| + <div class="span2"> | |
| + <%= render :partial => 'shared/graphs/sparkline', :locals => {… | |
| + Calls/Day | |
| + </div> | |
| + <div class="span2"> | |
| + <%= render :partial => 'shared/graphs/sparkline', :locals => {… | |
| + Calls/Week | |
| + </div> | |
| + <div class="span2"> | |
| + <%= render :partial => 'shared/graphs/sparkline', :locals => {… | |
| + Analysis/Hour | |
| + </div> | |
| + <div class="span2"> | |
| + <%= render :partial => 'shared/graphs/sparkline', :locals => {… | |
| + Analysis/Day | |
| + </div> | |
| + <div class="span2"> | |
| + <%= render :partial => 'shared/graphs/sparkline', :locals => {… | |
| + Analysis/Week | |
| + </div> | |
| +</div> | |
| diff --git a/app/views/shared/graphs/_call_results.html.erb b/app/views/shared/… | |
| @@ -12,9 +12,6 @@ line_data << raw("{ name: 'Answered', data: [ #{@call_results… | |
| <div id="<%= graph_id %>"></div> | |
| <%= javascript_tag do %> | |
| - | |
| - $(function () { | |
| - var chart; | |
| $(document).ready(function() { | |
| chart = new Highcharts.Chart({ | |
| chart: { | |
| @@ -53,8 +50,4 @@ line_data << raw("{ name: 'Answered', data: [ #{@call_results… | |
| series: [ <%= line_data %> ] | |
| }); | |
| }); | |
| - | |
| -}); | |
| - | |
| - | |
| <% end %> | |
| diff --git a/app/views/shared/graphs/_lines_by_type.html.erb b/app/views/shared… | |
| @@ -13,8 +13,6 @@ end | |
| <%= javascript_tag do %> | |
| - $(function () { | |
| - var chart; | |
| $(document).ready(function() { | |
| chart = new Highcharts.Chart({ | |
| chart: { | |
| @@ -54,7 +52,4 @@ end | |
| }); | |
| }); | |
| -}); | |
| - | |
| - | |
| <% end %> | |
| diff --git a/app/views/shared/graphs/_sparkline.html.erb b/app/views/shared/gra… | |
| @@ -0,0 +1,67 @@ | |
| +<% graph_id = "g" + rand(0x10000000).to_s %> | |
| + | |
| +<div class="sparkline" id="<%= graph_id %>"></div> | |
| + | |
| +<%= javascript_tag do %> | |
| + $(document).ready(function() { | |
| + var chart = new Highcharts.Chart({ | |
| + chart: { | |
| + renderTo: '<%= graph_id %>', | |
| + defaultSeriesType: 'area', | |
| + margin:[0,0,0,0], | |
| + // borderWidth: 0; | |
| + }, | |
| + title:{ | |
| + text:'' | |
| + }, | |
| + credits:{ | |
| + enabled:false | |
| + }, | |
| + xAxis: { | |
| + labels: { | |
| + enabled:false | |
| + } | |
| + }, | |
| + yAxis: { | |
| + maxPadding:0, | |
| + minPadding:0, | |
| + endOnTick:false, | |
| + labels: { | |
| + enabled:false | |
| + } | |
| + }, | |
| + legend: { | |
| + enabled:false | |
| + }, | |
| + tooltip: { | |
| + enabled:false | |
| + }, | |
| + plotOptions: { | |
| + series:{ | |
| + lineWidth:1, | |
| + shadow:false, | |
| + states:{ | |
| + hover:{ | |
| + lineWidth:1 | |
| + } | |
| + }, | |
| + marker:{ | |
| + //enabled:false, | |
| + radius:1, | |
| + states:{ | |
| + hover:{ | |
| + radius:2 | |
| + } | |
| + } | |
| + } | |
| + } | |
| + }, | |
| + series: [{ | |
| + color:'#666', | |
| + fillColor:'rgba(204,204,204,.25)', | |
| + data: [ <%= raw(points.join(", ")) %> ] | |
| + }] | |
| + }); | |
| +}); | |
| + | |
| +<% end %> | |
| diff --git a/db/migrate/20121228171549_initial_schema.rb b/db/migrate/201212281… | |
| @@ -94,8 +94,8 @@ class InitialSchema < ActiveRecord::Migration | |
| # Generated by the analysis job | |
| t.integer "analysis_job_id" | |
| - t.boolean "analysis_started_at" | |
| - t.boolean "analysis_completed_at" | |
| + t.timestamp "analysis_started_at" | |
| + t.timestamp "analysis_completed_at" | |
| t.float "peak_freq" | |
| t.text "peak_freq_data" | |
| t.text "line_type" | |
| @@ -140,9 +140,33 @@ class InitialSchema < ActiveRecord::Migration | |
| t.boolean "enabled", :default => true | |
| end | |
| + add_index :jobs, :project_id | |
| + add_index :lines, :number | |
| + add_index :lines, :project_id | |
| + add_index :line_attributes, :line_id | |
| + add_index :line_attributes, :project_id | |
| + add_index :calls, :number | |
| + add_index :calls, :job_id | |
| + add_index :calls, :provider_id | |
| + add_index :call_media, :call_id | |
| + add_index :call_media, :project_id | |
| + add_index :signature_fp, :signature_id | |
| + | |
| end | |
| def down | |
| + remove_index :jobs, :project_id | |
| + remove_index :lines, :number | |
| + remove_index :lines, :project_id | |
| + remove_index :line_attributes, :line_id | |
| + remove_index :line_attributes, :project_id | |
| + remove_index :calls, :number | |
| + remove_index :calls, :job_id | |
| + remove_index :calls, :provider_id | |
| + remove_index :call_media, :call_id | |
| + remove_index :call_media, :project_id | |
| + remove_index :signature_fp, :signature_id | |
| + | |
| drop_table "providers" | |
| drop_table "signature_fp" | |
| drop_table "signatures" | |
| diff --git a/db/migrate/20130106000000_add_indexes.rb b/db/migrate/201301060000… | |
| @@ -1,29 +0,0 @@ | |
| -class AddIndexes < ActiveRecord::Migration | |
| - def up | |
| - add_index :jobs, :project_id | |
| - add_index :lines, :number | |
| - add_index :lines, :project_id | |
| - add_index :line_attributes, :line_id | |
| - add_index :line_attributes, :project_id | |
| - add_index :calls, :number | |
| - add_index :calls, :job_id | |
| - add_index :calls, :provider_id | |
| - add_index :call_media, :call_id | |
| - add_index :call_media, :project_id | |
| - add_index :signature_fp, :signature_id | |
| - end | |
| - | |
| - def down | |
| - remove_index :jobs, :project_id | |
| - remove_index :lines, :number | |
| - remove_index :lines, :project_id | |
| - remove_index :line_attributes, :line_id | |
| - remove_index :line_attributes, :project_id | |
| - remove_index :calls, :number | |
| - remove_index :calls, :job_id | |
| - remove_index :calls, :provider_id | |
| - remove_index :call_media, :call_id | |
| - remove_index :call_media, :project_id | |
| - remove_index :signature_fp, :signature_id | |
| - end | |
| -end | |
| diff --git a/db/migrate/20130113004653_create_reportable_cache.rb b/db/migrate/… | |
| @@ -0,0 +1,40 @@ | |
| +class CreateReportableCache < ActiveRecord::Migration | |
| + | |
| + def self.up | |
| + create_table :reportable_cache, :force => true do |t| | |
| + t.string :model_name, :null => false, :limit => 100 | |
| + t.string :report_name, :null => false, :limit => 100 | |
| + t.string :grouping, :null => false, :limit => 10 | |
| + t.string :aggregation, :null => false, :limit => 10 | |
| + t.string :conditions, :null => false, :limit => 100 | |
| + t.float :value, :null => false, :default =>… | |
| + t.datetime :reporting_period, :null => false | |
| + | |
| + t.timestamps | |
| + end | |
| + | |
| + add_index :reportable_cache, [ | |
| + :model_name, | |
| + :report_name, | |
| + :grouping, | |
| + :aggregation, | |
| + :conditions | |
| + ], :name => :name_model_grouping_agregation | |
| + add_index :reportable_cache, [ | |
| + :model_name, | |
| + :report_name, | |
| + :grouping, | |
| + :aggregation, | |
| + :conditions, | |
| + :reporting_period | |
| + ], :unique => true, :name => :name_model_grouping_aggregation_period | |
| + end | |
| + | |
| + def self.down | |
| + remove_index :reportable_cache, :name => :name_model_grouping_agregation | |
| + remove_index :reportable_cache, :name => :name_model_grouping_aggregation_… | |
| + | |
| + drop_table :reportable_cache | |
| + end | |
| + | |
| +end | |
| diff --git a/db/schema.rb b/db/schema.rb | |
| @@ -11,7 +11,7 @@ | |
| # | |
| # It's strongly recommended to check this file into your version control syste… | |
| -ActiveRecord::Schema.define(:version => 20130106000000) do | |
| +ActiveRecord::Schema.define(:version => 20130113004653) do | |
| add_extension "intarray" | |
| @@ -44,8 +44,8 @@ ActiveRecord::Schema.define(:version => 20130106000000) do | |
| t.integer "ring_length" | |
| t.text "caller_id" | |
| t.integer "analysis_job_id" | |
| - t.boolean "analysis_started_at" | |
| - t.boolean "analysis_completed_at" | |
| + t.datetime "analysis_started_at" | |
| + t.datetime "analysis_completed_at" | |
| t.float "peak_freq" | |
| t.text "peak_freq_data" | |
| t.text "line_type" | |
| @@ -121,6 +121,21 @@ ActiveRecord::Schema.define(:version => 20130106000000) do | |
| t.boolean "enabled", :default => true | |
| end | |
| + create_table "reportable_cache", :force => true do |t| | |
| + t.string "model_name", :limit => 100, :null => fa… | |
| + t.string "report_name", :limit => 100, :null => fa… | |
| + t.string "grouping", :limit => 10, :null => fa… | |
| + t.string "aggregation", :limit => 10, :null => fa… | |
| + t.string "conditions", :limit => 100, :null => fa… | |
| + t.float "value", :default => 0.0, :null => fa… | |
| + t.datetime "reporting_period", :null => fa… | |
| + t.datetime "created_at", :null => fa… | |
| + t.datetime "updated_at", :null => fa… | |
| + end | |
| + | |
| + add_index "reportable_cache", ["model_name", "report_name", "grouping", "agg… | |
| + add_index "reportable_cache", ["model_name", "report_name", "grouping", "agg… | |
| + | |
| create_table "settings", :force => true do |t| | |
| t.string "var", :null => false | |
| t.text "value" | |
| diff --git a/lib/warvox/jobs/analysis.rb b/lib/warvox/jobs/analysis.rb | |
| @@ -148,7 +148,7 @@ class Analysis < Base | |
| def run_analyze_call(cid, jid) | |
| - dr = Call.find(cid) | |
| + dr = Call.find(cid, :include => :job) | |
| dr.analysis_started_at = Time.now.utc | |
| dr.analysis_job_id = jid | |
| dr.save |