Group attendance properties into a json key #181

Merged
bustikiller merged 1 commits from groups-attendance-format into main 2024-12-10 07:46:20 +00:00
2 changed files with 34 additions and 17 deletions

View File

@ -2,7 +2,18 @@
class GroupsController < ApplicationController
def index
render json: Groups::SummaryQuery.new.call.as_json
query_result = Groups::SummaryQuery.new.call.as_json.map(&:deep_symbolize_keys).map do |group|
{
id: group[:id],
name: group[:name],
icon: group[:icon],
color: group[:color],
parent_id: group[:parent_id],
attendance: group.slice(:total, :considered, :invited, :confirmed, :declined, :tentative)
}
end
render json: query_result
end
def create

View File

@ -12,13 +12,17 @@ RSpec.describe 'groups', type: :request do
schema type: :array,
items: {
type: :object,
required: %i[id name icon parent_id color total considered invited confirmed declined tentative],
required: %i[id name icon parent_id color attendance],
properties: {
id: { type: :string, format: :uuid, required: true },
name: { type: :string },
icon: { type: :string, example: 'pi pi-crown', description: 'The CSS classes used by the icon' },
parent_id: { type: :string, format: :uuid },
color: { type: :string, pattern: '^#(?:[0-9a-fA-F]{3}){1,2}$' },
attendance: {
type: :object,
required: %i[total considered invited confirmed declined tentative],
properties: {
total: { type: :integer, minimum: 0, description: 'Total number of guests in any status' },
considered: { type: :integer, minimum: 0 },
invited: { type: :integer, minimum: 0 },
@ -27,6 +31,8 @@ RSpec.describe 'groups', type: :request do
tentative: { type: :integer, minimum: 0 }
}
}
}
}
xit
end
regular_api_responses