BigW Consortium Gitlab

analytics_issue_entity.rb 605 Bytes
Newer Older
1
class AnalyticsIssueEntity < Grape::Entity
2
  include RequestAwareEntity
3
  include EntityDateHelper
4 5 6 7

  expose :title
  expose :author, using: UserEntity

8 9 10 11
  expose :iid do |object|
    object[:iid].to_s
  end

12
  expose :total_time do |object|
13
    distance_of_time_as_hash(object[:total_time].to_f)
14 15
  end

16
  expose(:created_at) do |object|
17 18 19 20
    interval_in_words(object[:created_at])
  end

  expose :url do |object|
21
    url_to(:namespace_project_issue, id: object[:iid].to_s)
22 23 24 25
  end

  private

26
  def url_to(route, id)
27
    public_send("#{route}_url", request.project.namespace, request.project, id)
28 29
  end
end