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
|
2022-01-12 09:15:13 +00:00
|
|
|
expose :project_path do |object|
|
|
|
|
object[:project_path]
|
|
|
|
end
|
2016-11-14 17:05:13 +00:00
|
|
|
|
2022-01-17 09:15:55 +00:00
|
|
|
expose :namespace_full_path do |object|
|
|
|
|
object[:namespace_path]
|
|
|
|
end
|
|
|
|
|
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
|
|
|
|
|
2022-05-25 06:08:38 +00:00
|
|
|
expose :end_event_timestamp do |object|
|
|
|
|
object[:end_event_timestamp] && interval_in_words(object[:end_event_timestamp])
|
|
|
|
end
|
|
|
|
|
2016-11-14 17:05:13 +00:00
|
|
|
private
|
|
|
|
|
2019-07-04 14:42:31 +00:00
|
|
|
def url_to(route, object)
|
2019-08-05 21:15:00 +00:00
|
|
|
public_send("#{route}_url", object[:namespace_path], object[:project_path], object[:iid].to_s) # rubocop:disable GitlabSecurity/PublicSend
|
2016-11-14 17:05:13 +00:00
|
|
|
end
|
|
|
|
end
|