2016-11-17 07:22:27 -05:00
|
|
|
class AnalyticsIssueEntity < Grape::Entity
|
2016-11-14 12:05:13 -05:00
|
|
|
include RequestAwareEntity
|
2016-11-15 05:36:39 -05:00
|
|
|
include EntityDateHelper
|
2016-11-14 12:05:13 -05:00
|
|
|
|
|
|
|
expose :title
|
|
|
|
expose :author, using: UserEntity
|
|
|
|
|
2016-11-16 09:55:20 -05:00
|
|
|
expose :iid do |object|
|
|
|
|
object[:iid].to_s
|
|
|
|
end
|
|
|
|
|
2016-11-14 12:05:13 -05:00
|
|
|
expose :total_time do |object|
|
2016-11-16 09:55:20 -05:00
|
|
|
distance_of_time_as_hash(object[:total_time].to_f)
|
2016-11-14 12:05:13 -05:00
|
|
|
end
|
|
|
|
|
2016-11-15 04:33:01 -05:00
|
|
|
expose(:created_at) do |object|
|
2016-11-14 12:05:13 -05:00
|
|
|
interval_in_words(object[:created_at])
|
|
|
|
end
|
|
|
|
|
|
|
|
expose :url do |object|
|
2016-11-17 07:22:27 -05:00
|
|
|
url_to(:namespace_project_issue, id: object[:iid].to_s)
|
2016-11-14 12:05:13 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2016-11-15 04:33:01 -05:00
|
|
|
def url_to(route, id)
|
2017-08-03 22:20:34 -04:00
|
|
|
public_send("#{route}_url", request.project.namespace, request.project, id) # rubocop:disable GitlabSecurity/PublicSend
|
2016-11-14 12:05:13 -05:00
|
|
|
end
|
|
|
|
end
|