2018-07-19 14:43:13 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
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|
|
2019-07-04 10:42:31 -04:00
|
|
|
url_to(:namespace_project_issue, object)
|
2016-11-14 12:05:13 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2019-07-04 10:42:31 -04:00
|
|
|
def url_to(route, object)
|
2019-08-05 17:15:00 -04:00
|
|
|
public_send("#{route}_url", object[:namespace_path], object[:project_path], object[:iid].to_s) # rubocop:disable GitlabSecurity/PublicSend
|
2016-11-14 12:05:13 -05:00
|
|
|
end
|
|
|
|
end
|