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
|
2022-01-12 04:15:13 -05:00
|
|
|
expose :project_path do |object|
|
|
|
|
object[:project_path]
|
|
|
|
end
|
2016-11-14 12:05:13 -05:00
|
|
|
|
2022-01-17 04:15:55 -05:00
|
|
|
expose :namespace_full_path do |object|
|
|
|
|
object[:namespace_path]
|
|
|
|
end
|
|
|
|
|
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
|
|
|
|
|
2022-05-25 02:08:38 -04:00
|
|
|
expose :end_event_timestamp do |object|
|
|
|
|
object[:end_event_timestamp] && interval_in_words(object[:end_event_timestamp])
|
|
|
|
end
|
|
|
|
|
2016-11-14 12:05:13 -05:00
|
|
|
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
|