Merge pull request 'Group attendance properties into a json key' (#181) from groups-attendance-format into main
Reviewed-on: #181
This commit is contained in:
commit
70bbf79a5a
@ -2,7 +2,18 @@
|
|||||||
|
|
||||||
class GroupsController < ApplicationController
|
class GroupsController < ApplicationController
|
||||||
def index
|
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
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
@ -10,23 +10,29 @@ RSpec.describe 'groups', type: :request do
|
|||||||
parameter Swagger::Schema::SLUG
|
parameter Swagger::Schema::SLUG
|
||||||
response(200, 'successful') do
|
response(200, 'successful') do
|
||||||
schema type: :array,
|
schema type: :array,
|
||||||
items: {
|
items: {
|
||||||
type: :object,
|
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: {
|
properties: {
|
||||||
id: { type: :string, format: :uuid, required: true },
|
id: { type: :string, format: :uuid, required: true },
|
||||||
name: { type: :string },
|
name: { type: :string },
|
||||||
icon: { type: :string, example: 'pi pi-crown', description: 'The CSS classes used by the icon' },
|
icon: { type: :string, example: 'pi pi-crown', description: 'The CSS classes used by the icon' },
|
||||||
parent_id: { type: :string, format: :uuid },
|
parent_id: { type: :string, format: :uuid },
|
||||||
color: { type: :string, pattern: '^#(?:[0-9a-fA-F]{3}){1,2}$' },
|
color: { type: :string, pattern: '^#(?:[0-9a-fA-F]{3}){1,2}$' },
|
||||||
total: { type: :integer, minimum: 0, description: 'Total number of guests in any status' },
|
attendance: {
|
||||||
considered: { type: :integer, minimum: 0 },
|
type: :object,
|
||||||
invited: { type: :integer, minimum: 0 },
|
required: %i[total considered invited confirmed declined tentative],
|
||||||
confirmed: { type: :integer, minimum: 0 },
|
properties: {
|
||||||
declined: { type: :integer, minimum: 0 },
|
total: { type: :integer, minimum: 0, description: 'Total number of guests in any status' },
|
||||||
tentative: { type: :integer, minimum: 0 }
|
considered: { type: :integer, minimum: 0 },
|
||||||
|
invited: { type: :integer, minimum: 0 },
|
||||||
|
confirmed: { type: :integer, minimum: 0 },
|
||||||
|
declined: { type: :integer, minimum: 0 },
|
||||||
|
tentative: { type: :integer, minimum: 0 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
xit
|
xit
|
||||||
end
|
end
|
||||||
regular_api_responses
|
regular_api_responses
|
||||||
|
Loading…
x
Reference in New Issue
Block a user