This repository has been archived on 2024-06-09. You can view files and clone it, but cannot push or open issues/pull-requests.
2021-10-14 20:44:59 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class REST::Admin::MeasureSerializer < ActiveModel::Serializer
|
2022-03-09 08:52:32 +01:00
|
|
|
attributes :key, :unit, :total
|
|
|
|
|
|
|
|
attribute :human_value, if: -> { object.respond_to?(:value_to_human_value) }
|
|
|
|
attribute :previous_total, if: -> { object.total_in_time_range? }
|
|
|
|
attribute :data
|
2021-10-14 20:44:59 +02:00
|
|
|
|
|
|
|
def total
|
|
|
|
object.total.to_s
|
|
|
|
end
|
|
|
|
|
2022-03-09 08:52:32 +01:00
|
|
|
def human_value
|
|
|
|
object.value_to_human_value(object.total)
|
|
|
|
end
|
|
|
|
|
2021-10-14 20:44:59 +02:00
|
|
|
def previous_total
|
|
|
|
object.previous_total.to_s
|
|
|
|
end
|
|
|
|
end
|