Add collection serializer for bets
This commit is contained in:
parent
7955425c38
commit
123649a4f4
|
|
@ -0,0 +1,12 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class BetsSerializer < ActiveModel::Serializer::CollectionSerializer
|
||||
def serializable_hash(_adapter_options, _options, _adapter_instance)
|
||||
@object.group_by(&:team).map do |team, bets|
|
||||
{
|
||||
team: ActiveModelSerializers::SerializableResource.new(team).as_json,
|
||||
bets: bets.size
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Reference in New Issue