about summary refs log tree commit diff
path: root/app/serializers/rest/admin/cohort_serializer.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/serializers/rest/admin/cohort_serializer.rb')
-rw-r--r--app/serializers/rest/admin/cohort_serializer.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/app/serializers/rest/admin/cohort_serializer.rb b/app/serializers/rest/admin/cohort_serializer.rb
new file mode 100644
index 000000000..f68173616
--- /dev/null
+++ b/app/serializers/rest/admin/cohort_serializer.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class REST::Admin::CohortSerializer < ActiveModel::Serializer
+  attributes :period, :frequency
+
+  class CohortDataSerializer < ActiveModel::Serializer
+    attributes :date, :rate, :value
+
+    def date
+      object.date.iso8601
+    end
+  end
+
+  has_many :data, serializer: CohortDataSerializer
+
+  def period
+    object.period.iso8601
+  end
+end