Skip to content

Instantly share code, notes, and snippets.

@pc-m
Created June 27, 2023 20:00
Show Gist options
  • Select an option

  • Save pc-m/3c8d184adafbf287c13dee082bcac4f1 to your computer and use it in GitHub Desktop.

Select an option

Save pc-m/3c8d184adafbf287c13dee082bcac4f1 to your computer and use it in GitHub Desktop.
Speed-up wazo-confd GET /users/<uuid> requests
diff --git a/xivo_dao/resources/user/persistor.py b/xivo_dao/resources/user/persistor.py
index 4a2fe27d..2eb6e9fd 100644
--- a/xivo_dao/resources/user/persistor.py
+++ b/xivo_dao/resources/user/persistor.py
@@ -1,6 +1,7 @@
# Copyright 2015-2022 The Wazo Authors (see the AUTHORS file)
# SPDX-License-Identifier: GPL-3.0-or-later
+from sqlalchemy.orm import joinedload
from sqlalchemy.sql import func
from xivo_dao.alchemy.userfeatures import UserFeatures as User
@@ -23,7 +24,9 @@ class UserPersistor(CriteriaBuilderMixin, BasePersistor):
self.tenant_uuids = tenant_uuids
def find_by_id_uuid(self, id):
- query = self.session.query(User)
+ query = self.session.query(User).options(
+ joinedload('rightcall_members').selectinload('rightcall').noload('rightcall_members')
+ )
if isinstance(id, int):
query = query.filter_by(id=id)
else:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment