diff options
author | James Lopez <james@jameslopez.es> | 2016-11-17 15:22:27 +0300 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2016-11-17 15:22:27 +0300 |
commit | ed39d61d746925e49d952bd8169499d3200ae68b (patch) | |
tree | 33128144980f4b62e96309e9ed4c23133422159b /app/serializers/analytics_issue_entity.rb | |
parent | f9de157e70234748cf4285fafda7b3ec13862f5c (diff) |
refactor events facade so it uses separate classes and refactor query stuff
Diffstat (limited to 'app/serializers/analytics_issue_entity.rb')
-rw-r--r-- | app/serializers/analytics_issue_entity.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/app/serializers/analytics_issue_entity.rb b/app/serializers/analytics_issue_entity.rb new file mode 100644 index 00000000000..44c50f18613 --- /dev/null +++ b/app/serializers/analytics_issue_entity.rb @@ -0,0 +1,29 @@ +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, id: object[:iid].to_s) + end + + private + + def url_to(route, id) + public_send("#{route}_url", request.project.namespace, request.project, id) + end +end |