about summary refs log tree commit diff
path: root/app/serializers
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2021-10-14 20:55:16 +0200
committerClaire <claire.github-309c@sitedethib.com>2021-10-14 21:44:57 +0200
commit694c073d1f94a54a0ccf19299e06f1de849c6edb (patch)
tree77e9855f70000396b8a6b793ac8a8dbb61c82783 /app/serializers
parentebf2c3195615bb524f6908e84f99887c8775cbc3 (diff)
parent9b978872cc1a86c7d82afda4060c909dc7ca2536 (diff)
Merge branch 'main' into glitch-soc/merge-upstream
Conflicts:
- `app/controllers/admin/dashboard_controller.rb`:
  Upstream completely redesigned the admin dashboard.
  glitch-soc tracked extra features, but that list is
  gone.
  Followed upstram.
- `app/views/admin/dashboard/index.html.haml`
  Upstream completely redesigned the admin dashboard.
  glitch-soc tracked extra features, but that list is
  gone.
  Followed upstram.
Diffstat (limited to 'app/serializers')
-rw-r--r--app/serializers/rest/admin/cohort_serializer.rb19
-rw-r--r--app/serializers/rest/admin/dimension_serializer.rb5
-rw-r--r--app/serializers/rest/admin/measure_serializer.rb13
-rw-r--r--app/serializers/rest/admin/tag_serializer.rb13
4 files changed, 50 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..56b35c699
--- /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, :percent, :value
+
+    def date
+      object.date.iso8601
+    end
+  end
+
+  has_many :data, serializer: CohortDataSerializer
+
+  def period
+    object.period.iso8601
+  end
+end
diff --git a/app/serializers/rest/admin/dimension_serializer.rb b/app/serializers/rest/admin/dimension_serializer.rb
new file mode 100644
index 000000000..a00b6ecd7
--- /dev/null
+++ b/app/serializers/rest/admin/dimension_serializer.rb
@@ -0,0 +1,5 @@
+# frozen_string_literal: true
+
+class REST::Admin::DimensionSerializer < ActiveModel::Serializer
+  attributes :key, :data
+end
diff --git a/app/serializers/rest/admin/measure_serializer.rb b/app/serializers/rest/admin/measure_serializer.rb
new file mode 100644
index 000000000..81d655c1a
--- /dev/null
+++ b/app/serializers/rest/admin/measure_serializer.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class REST::Admin::MeasureSerializer < ActiveModel::Serializer
+  attributes :key, :total, :previous_total, :data
+
+  def total
+    object.total.to_s
+  end
+
+  def previous_total
+    object.previous_total.to_s
+  end
+end
diff --git a/app/serializers/rest/admin/tag_serializer.rb b/app/serializers/rest/admin/tag_serializer.rb
new file mode 100644
index 000000000..425ba4ba3
--- /dev/null
+++ b/app/serializers/rest/admin/tag_serializer.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class REST::Admin::TagSerializer < REST::TagSerializer
+  attributes :id, :trendable, :usable, :requires_review
+
+  def id
+    object.id.to_s
+  end
+
+  def requires_review
+    object.requires_review?
+  end
+end