2018-07-19 18:43:13 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-11-17 12:22:27 +00:00
|
|
|
class AnalyticsIssueEntity < Grape::Entity
|
2016-11-14 17:05:13 +00:00
|
|
|
include RequestAwareEntity
|
2016-11-15 10:36:39 +00:00
|
|
|
include EntityDateHelper
|
2016-11-14 17:05:13 +00:00
|
|
|
|
|
|
|
expose :title
|
|
|
|
expose :author, using: UserEntity
|
|
|
|
|
2016-11-16 14:55:20 +00:00
|
|
|
expose :iid do |object|
|
|
|
|
object[:iid].to_s
|
|
|
|
end
|
|
|
|
|
2016-11-14 17:05:13 +00:00
|
|
|
expose :total_time do |object|
|
2016-11-16 14:55:20 +00:00
|
|
|
distance_of_time_as_hash(object[:total_time].to_f)
|
2016-11-14 17:05:13 +00:00
|
|
|
end
|
|
|
|
|
2016-11-15 09:33:01 +00:00
|
|
|
expose(:created_at) do |object|
|
2016-11-14 17:05:13 +00:00
|
|
|
interval_in_words(object[:created_at])
|
|
|
|
end
|
|
|
|
|
|
|
|
expose :url do |object|
|
2019-07-04 14:42:31 +00:00
|
|
|
url_to(:namespace_project_issue, object)
|
2016-11-14 17:05:13 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2019-07-04 14:42:31 +00:00
|
|
|
def url_to(route, object)
|
|
|
|
public_send("#{route}_url", object[:path], object[:name], object[:iid].to_s) # rubocop:disable GitlabSecurity/PublicSend
|
2016-11-14 17:05:13 +00:00
|
|
|
end
|
|
|
|
end
|