Return number of guests per group

This commit is contained in:
Manuel Bustillo 2024-08-11 18:56:38 +02:00
parent cca869a0c4
commit de93ffb643
2 changed files with 6 additions and 1 deletions

View File

@ -1,5 +1,6 @@
class GroupsController < ApplicationController
def index
render jsonapi: Group.where(parent_id: nil), include: [children: [children: [:children]]]
roots = Group.where(parent_id: nil)
render jsonapi: roots, include: [children: [children: [:children]]]
end
end

View File

@ -4,4 +4,8 @@ class SerializableGroup < JSONAPI::Serializable::Resource
attributes :name, :icon
has_many :children
attribute :guest_count do
@object.guests.count
end
end