diff --git a/admin/app/admin/score_export.rb b/admin/app/admin/score_export.rb index 5e4802a0d..85d1aac0c 100644 --- a/admin/app/admin/score_export.rb +++ b/admin/app/admin/score_export.rb @@ -1,4 +1,4 @@ -ActiveAdmin.register_page "Score Exports" do +ActiveAdmin.register_page "Download CSV" do menu :parent => 'Score' page_action :create_csv, :method => :post do @@ -18,20 +18,18 @@ ActiveAdmin.register_page "Score Exports" do end_time = "#{end_time}" end - puts "start_time #{start_time}, end_time #{end_time}" - scores = ScoreHistory - .select("from_city, from_regions.regionname as from_region_name, from_countries.countryname as from_country_name, from_isp, - to_city, to_regions.regionname as to_region_name, to_countries.countryname as to_country_name, to_isp, - min(score_histories.score) as min_latency, max(score_histories.score) as max_latency, avg(score_histories.score) as mean_latency, median(CAST(score_histories.score AS NUMERIC)) as median_latency, count(score_histories.score) as score_count") - .joins('LEFT JOIN countries AS from_countries ON from_countries.countrycode = from_country') - .joins('LEFT JOIN countries AS to_countries ON to_countries.countrycode = to_country') - .joins('LEFT JOIN regions AS from_regions ON from_regions.region = from_region') - .joins('LEFT JOIN regions AS to_regions ON to_regions.region = to_region') - .where("score_dt BETWEEN DATE '#{start_time}' AND DATE '#{end_time}'") - .order('from_city, from_regions.regionname, from_countries.countryname, from_isp, to_city, to_regions.regionname, to_countries.countryname, to_isp') - .group('from_city, from_regions.regionname, from_countries.countryname, from_isp, to_city, to_regions.regionname, to_countries.countryname, to_isp') - .limit(1_000_000) + .select("from_city, from_regions.regionname as from_region_name, from_countries.countryname as from_country_name, from_isp, + to_city, to_regions.regionname as to_region_name, to_countries.countryname as to_country_name, to_isp, + min(score_histories.score) as min_latency, max(score_histories.score) as max_latency, avg(score_histories.score) as mean_latency, median(CAST(score_histories.score AS NUMERIC)) as median_latency, count(score_histories.score) as score_count") + .joins('LEFT JOIN countries AS from_countries ON from_countries.countrycode = from_country') + .joins('LEFT JOIN countries AS to_countries ON to_countries.countrycode = to_country') + .joins('LEFT JOIN regions AS from_regions ON from_regions.region = from_region') + .joins('LEFT JOIN regions AS to_regions ON to_regions.region = to_region') + .where("score_dt BETWEEN DATE '#{start_time}' AND DATE '#{end_time}'") + .order('from_city, from_regions.regionname, from_countries.countryname, from_isp, to_city, to_regions.regionname, to_countries.countryname, to_isp') + .group('from_city, from_regions.regionname, from_countries.countryname, from_isp, to_city, to_regions.regionname, to_countries.countryname, to_isp') + .limit(1_000_000) csv_string = CSV.generate do |csv| @@ -52,10 +50,10 @@ ActiveAdmin.register_page "Score Exports" do end - content :title => "Score Exports" do + content :title => "Export Score" do columns do column do - semantic_form_for :score_exports, :url => admin_score_exports_create_csv_path, :builder => ActiveAdmin::FormBuilder do |f| + semantic_form_for :score_exports, :url => admin_download_csv_create_csv_path, :builder => ActiveAdmin::FormBuilder do |f| f.inputs do f.input :start, :as => :datepicker f.input :end, :as => :datepicker @@ -78,7 +76,7 @@ ActiveAdmin.register_page "Score Exports" do div do span do "This report uses the score_histories table, which can lag up to 1 hour behind data. You can force a score_history sweep by going to" end span do link_to "Resque", "#{Gon.global.prefix}resque/schedule" end - span do " and then running ScoreHistorySweeper. When the job count goes from 1 to 0, the score_histories table is now completely up-to-date, and you can make a 'fresh' CSV." end + span do " and then clicking 'Queue Now' for ScoreHistorySweeper. When the job count goes from 1 to 0, the score_histories table is now completely up-to-date, and you can make a 'fresh' CSV." end end end end