Sha256: c7186a607655a7b7aa5928b075723a659f448df44a4457558d6a905603d1aa67

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

class PathResponseTimeView < ActiveRecord::Migration
  def up
    execute <<-SQL
    DROP VIEW IF EXISTS #{Landable.configuration.database_schema_prefix}landable_traffic.path_response_time__by_time;
  CREATE OR REPLACE VIEW #{Landable.configuration.database_schema_prefix}landable_traffic.path_response_time__by_time
  AS
  SELECT *
  FROM
  (
    SELECT
     p.path_id as path_id
    , p.path as path
    ,round(avg(pv.response_time), 3) as "average response time (ms)"
    FROM #{Landable.configuration.database_schema_prefix}landable_traffic.page_views pv
      JOIN #{Landable.configuration.database_schema_prefix}landable_traffic.paths p
        on p.path_id = pv.path_id
    group by p.path_id, p.path
  ) agg1
  order by agg1."average response time (ms)" desc
  ;

  COMMENT ON VIEW #{Landable.configuration.database_schema_prefix}landable_traffic.path_response_time__by_time IS $$
  The view path_response_time__by_time returns the paths displayed and the average reponse time (in ms) for each page of the site.  This list is ordered by response time, decending.$$;
  SQL
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
landable-1.14.0 db/migrate/20140602213937_path_response_time_view.rb
landable-1.13.2 db/migrate/20140602213937_path_response_time_view.rb