gitlab-org--gitlab-foss/app/serializers/analytics_issue_entity.rb
Gosia Ksionek 6c5e948013 Fix error on project name
Add project path to sql query to build proper path
2019-08-05 21:15:00 +00:00

31 lines
688 B
Ruby

# frozen_string_literal: true
class AnalyticsIssueEntity < Grape::Entity
include RequestAwareEntity
include EntityDateHelper
expose :title
expose :author, using: UserEntity
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|
url_to(:namespace_project_issue, object)
end
private
def url_to(route, object)
public_send("#{route}_url", object[:namespace_path], object[:project_path], object[:iid].to_s) # rubocop:disable GitlabSecurity/PublicSend
end
end