diff options
author | Sean McGivern <sean@gitlab.com> | 2017-04-06 15:12:12 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-04-14 16:20:55 +0300 |
commit | ac0146a08eb2ec6c23b46ea014376b7a70a21415 (patch) | |
tree | 447f113a087fe5c001e4b3a6b441ef9ac65680c0 /app/serializers/cohort_entity.rb | |
parent | 61eaf4fe1755799c42e474019759e3859e6b2926 (diff) |
Use serializer for formatting cohorts data
Diffstat (limited to 'app/serializers/cohort_entity.rb')
-rw-r--r-- | app/serializers/cohort_entity.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/app/serializers/cohort_entity.rb b/app/serializers/cohort_entity.rb new file mode 100644 index 00000000000..7cdba5b0484 --- /dev/null +++ b/app/serializers/cohort_entity.rb @@ -0,0 +1,17 @@ +class CohortEntity < Grape::Entity + include ActionView::Helpers::NumberHelper + + expose :registration_month do |cohort| + cohort[:registration_month].strftime('%b %Y') + end + + expose :total do |cohort| + number_with_delimiter(cohort[:total]) + end + + expose :inactive do |cohort| + number_with_delimiter(cohort[:inactive]) + end + + expose :activity_months, using: CohortActivityMonthEntity +end |