BigW Consortium Gitlab

Commit a9982762 by James Lopez

added analytics stage serializer and moved some info to the stage classes from the controller

parent 3268e377
class AnalyticsStageEntity < Grape::Entity
include EntityDateHelper
expose :stage, as: :title do |object|
object[:stage].to_s.capitalize
end
expose :description
expose :median, as: :value do |stage|
stage[:median] && !stage[:median].zero? ? distance_of_time_in_words(stage[:median]) : nil
end
end
class AnalyticsStageSerializer < BaseSerializer
entity AnalyticsStageEntity
end
module Gitlab
module CycleAnalytics
class BaseStage
attr_reader :stage, :description
def initialize(project:, options:, stage: stage)
@project = project
@options = options
......
module Gitlab
module CycleAnalytics
class CodeStage < BaseStage
def initialize(*args)
super(*args)
@description = "Time until first merge request"
end
def median
@fetcher.calculate_metric(:code,
Issue::Metrics.arel_table[:first_mentioned_in_commit_at],
......
module Gitlab
module CycleAnalytics
class IssueStage < BaseStage
def initialize(*args)
super(*args)
@description = "Time before an issue gets scheduled"
end
def median
@fetcher.calculate_metric(:issue,
Issue.arel_table[:created_at],
......
module Gitlab
module CycleAnalytics
class PlanStage < BaseStage
def initialize(*args)
super(*args)
@description = "Time before an issue starts implementation"
end
def median
@fetcher.calculate_metric(:plan,
[Issue::Metrics.arel_table[:first_associated_with_milestone_at],
......
module Gitlab
module CycleAnalytics
class ProductionStage < BaseStage
def initialize(*args)
super(*args)
@description = "From issue creation until deploy to production"
end
def median
@fetcher.calculate_metric(:production,
Issue.arel_table[:created_at],
......
module Gitlab
module CycleAnalytics
class ReviewStage < BaseStage
def initialize(*args)
super(*args)
@description = "Time between merge request creation and merge/close"
end
def median
@fetcher.calculate_metric(:review,
MergeRequest.arel_table[:created_at],
......
module Gitlab
module CycleAnalytics
class StagingStage < BaseStage
def initialize(*args)
super(*args)
@description = "From merge request merge until deploy to production"
end
def median
@fetcher.calculate_metric(:staging,
MergeRequest::Metrics.arel_table[:merged_at],
......
module Gitlab
module CycleAnalytics
class TestStage < BaseStage
def initialize(*args)
super(*args)
@description = "Total test time for all commits/merges"
end
def median
@fetcher.calculate_metric(:test,
MergeRequest::Metrics.arel_table[:latest_build_started_at],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment