Files
ubicloud/serializers/account.rb
Jeremy Evans 4ed5dbb8ba Avoid N+1 query issue when displaying project user page
The N+1 query issue was introduced when the :project_id option
was added to the Account serializer, because it does a query
per Account being displayed.

Avoid this issue by not using serializers for project user
page.  Serializers only make sense as a separate object if
you want to share the same type of serialization in multiple
places, and you actually need to serialize.  Multiple API
routes that need the same type of serialization.  For other
places, it is both simpler and faster to underlying objects
directly instead of using a serializer.

To get the subject tags for the users, extract a
SubjectTag.subject_id_map_for_project_and_accounts method,
and use that for the project user page as well as the form
submission handler for updating policies for users.

As they are no longer used, remove the Account#subject_tags
association and the ProjectInvitation serializer.
2025-01-09 09:55:55 -08:00

12 lines
204 B
Ruby

# frozen_string_literal: true
class Serializers::Account < Serializers::Base
def self.serialize_internal(a, options = {})
{
id: a.id,
ubid: a.ubid,
email: a.email
}
end
end