diff options
author | Claire <claire.github-309c@sitedethib.com> | 2021-10-14 22:57:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-14 22:57:41 +0200 |
commit | b6f24ef0fb8b594c38c29090518c21af051b63b7 (patch) | |
tree | 5cec6a6b13dfd062848c74ae8e041c589ae40d00 /app/serializers | |
parent | ebf2c3195615bb524f6908e84f99887c8775cbc3 (diff) | |
parent | 6964952d5f242ca936de9df361185b3e70a99ca4 (diff) |
Merge pull request #1622 from ClearlyClaire/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/serializers')
-rw-r--r-- | app/serializers/rest/admin/cohort_serializer.rb | 19 | ||||
-rw-r--r-- | app/serializers/rest/admin/dimension_serializer.rb | 5 | ||||
-rw-r--r-- | app/serializers/rest/admin/measure_serializer.rb | 13 | ||||
-rw-r--r-- | app/serializers/rest/admin/tag_serializer.rb | 13 |
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 |