about summary refs log tree commit diff
path: root/app/serializers/rest/admin/cohort_serializer.rb
blob: 56b35c6991bc85bb7bd00a2d35fc8bdce3fc2bea (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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