2018-11-18 11:00:15 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
class AnalyticsIssueEntity < Grape::Entity
|
|
|
|
include RequestAwareEntity
|
|
|
|
include EntityDateHelper
|
|
|
|
|
|
|
|
expose :title
|
|
|
|
expose :author, using: UserEntity
|
2022-03-02 08:16:31 +05:30
|
|
|
expose :project_path do |object|
|
|
|
|
object[:project_path]
|
|
|
|
end
|
|
|
|
|
|
|
|
expose :namespace_full_path do |object|
|
|
|
|
object[:namespace_path]
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
expose :iid do |object|
|
|
|
|
object[:iid].to_s
|
|
|
|
end
|
|
|
|
|
|
|
|
expose :total_time do |object|
|
|
|
|
distance_of_time_as_hash(object[:total_time].to_f)
|
|
|
|
end
|
|
|
|
|
|
|
|
expose(:created_at) do |object|
|
|
|
|
interval_in_words(object[:created_at])
|
|
|
|
end
|
|
|
|
|
|
|
|
expose :url do |object|
|
2019-10-12 21:52:04 +05:30
|
|
|
url_to(:namespace_project_issue, object)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2022-07-23 23:45:48 +05:30
|
|
|
expose :end_event_timestamp do |object|
|
|
|
|
object[:end_event_timestamp] && interval_in_words(object[:end_event_timestamp])
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
private
|
|
|
|
|
2019-10-12 21:52:04 +05:30
|
|
|
def url_to(route, object)
|
|
|
|
public_send("#{route}_url", object[:namespace_path], object[:project_path], object[:iid].to_s) # rubocop:disable GitlabSecurity/PublicSend
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|