summaryrefslogtreecommitdiff
path: root/app/serializers
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2016-11-17 13:22:27 +0100
committerJames Lopez <james@jameslopez.es>2016-11-17 13:22:27 +0100
commited39d61d746925e49d952bd8169499d3200ae68b (patch)
tree33128144980f4b62e96309e9ed4c23133422159b /app/serializers
parentf9de157e70234748cf4285fafda7b3ec13862f5c (diff)
downloadgitlab-ce-ed39d61d746925e49d952bd8169499d3200ae68b.tar.gz
refactor events facade so it uses separate classes and refactor query stuff
Diffstat (limited to 'app/serializers')
-rw-r--r--app/serializers/analytics_generic_serializer.rb2
-rw-r--r--app/serializers/analytics_issue_entity.rb (renamed from app/serializers/analytics_generic_entity.rb)5
-rw-r--r--app/serializers/analytics_issue_serializer.rb3
-rw-r--r--app/serializers/analytics_merge_request_entity.rb7
-rw-r--r--app/serializers/analytics_merge_request_serializer.rb3
5 files changed, 15 insertions, 5 deletions
diff --git a/app/serializers/analytics_generic_serializer.rb b/app/serializers/analytics_generic_serializer.rb
index 9000e25a91d..9f4859e8410 100644
--- a/app/serializers/analytics_generic_serializer.rb
+++ b/app/serializers/analytics_generic_serializer.rb
@@ -1,6 +1,4 @@
class AnalyticsGenericSerializer < BaseSerializer
- entity AnalyticsGenericEntity
-
def represent(resource, opts = {})
resource.symbolize_keys!
diff --git a/app/serializers/analytics_generic_entity.rb b/app/serializers/analytics_issue_entity.rb
index 203cf39b940..44c50f18613 100644
--- a/app/serializers/analytics_generic_entity.rb
+++ b/app/serializers/analytics_issue_entity.rb
@@ -1,9 +1,8 @@
-class AnalyticsGenericEntity < Grape::Entity
+class AnalyticsIssueEntity < Grape::Entity
include RequestAwareEntity
include EntityDateHelper
expose :title
- expose :state, if: ->(_instance, options) { options[:request].entity == :merge_request }
expose :author, using: UserEntity
expose :iid do |object|
@@ -19,7 +18,7 @@ class AnalyticsGenericEntity < Grape::Entity
end
expose :url do |object|
- url_to("namespace_project_#{request.entity}".to_sym, id: object[:iid].to_s)
+ url_to(:namespace_project_issue, id: object[:iid].to_s)
end
private
diff --git a/app/serializers/analytics_issue_serializer.rb b/app/serializers/analytics_issue_serializer.rb
new file mode 100644
index 00000000000..4fb3e8f1bb4
--- /dev/null
+++ b/app/serializers/analytics_issue_serializer.rb
@@ -0,0 +1,3 @@
+class AnalyticsIssueSerializer < AnalyticsGenericSerializer
+ entity AnalyticsIssueEntity
+end
diff --git a/app/serializers/analytics_merge_request_entity.rb b/app/serializers/analytics_merge_request_entity.rb
new file mode 100644
index 00000000000..888265eaa38
--- /dev/null
+++ b/app/serializers/analytics_merge_request_entity.rb
@@ -0,0 +1,7 @@
+class AnalyticsMergeRequestEntity < AnalyticsIssueEntity
+ expose :state
+
+ expose :url do |object|
+ url_to(:namespace_project_merge_request, id: object[:iid].to_s)
+ end
+end
diff --git a/app/serializers/analytics_merge_request_serializer.rb b/app/serializers/analytics_merge_request_serializer.rb
new file mode 100644
index 00000000000..4622a1dd855
--- /dev/null
+++ b/app/serializers/analytics_merge_request_serializer.rb
@@ -0,0 +1,3 @@
+class AnalyticsMergeRequestSerializer < AnalyticsGenericSerializer
+ entity AnalyticsMergeRequestEntity
+end