Skip to content
Snippets Groups Projects
Commit 8ccea81c authored by Timothy Andrew's avatar Timothy Andrew
Browse files

Display numbers for the "Issue (Tracker)" cycle analytics metric.

1. Code is messy and untested, but it is a start.
parent 516c838a
No related branches found
No related tags found
1 merge request!5986Cycle Analytics: first iteration
class Projects::CycleAnalyticsController < Projects::ApplicationController
def show
@metrics = {
issue: issue
}
end
private
def issue
query = <<-HEREDOC
WITH ordered_data AS (
SELECT extract(milliseconds FROM (COALESCE(first_associated_with_milestone_at, first_added_to_board_at) - issues.created_at)) AS data_point,
row_number() over (order by (COALESCE(first_associated_with_milestone_at, first_added_to_board_at) - issues.created_at)) as row_id
FROM issues
INNER JOIN issue_metrics ON issue_metrics.issue_id = issues.id
WHERE COALESCE(first_associated_with_milestone_at, first_added_to_board_at) IS NOT NULL
),
ct AS (
SELECT count(1) AS ct
FROM ordered_data
)
SELECT avg(data_point) AS median
FROM ordered_data
WHERE row_id between (select ct from ct)/2.0 and (select ct from ct)/2.0 + 1;
HEREDOC
ActiveRecord::Base.connection.execute(query).to_a.first['median']
end
end
%pre= @metrics
Loading
Loading
@@ -779,6 +779,8 @@ Rails.application.routes.draw do
 
resources :environments
 
resource :cycle_analytics
resources :builds, only: [:index, :show], constraints: { id: /\d+/ } do
collection do
post :cancel_all
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment