Optimize insert app role to user

This commit is contained in:
Luka Radenovic 2022-05-16 14:01:56 +02:00 committed by Maarten de Waard
parent bc85575e9b
commit 09f1d2e00a

View file

@ -81,13 +81,12 @@ class UserService:
@staticmethod @staticmethod
def __insertAppRoleToUser(userId, userRes): def __insertAppRoleToUser(userId, userRes):
app_role = AppRole.query.filter_by(user_id=userId)
apps = App.query.all() apps = App.query.all()
app_roles = [] app_roles = []
for app in apps: for app in apps:
tmp_app_role = app_role.filter_by(app_id=app.id).first() tmp_app_role = AppRole.query.filter_by(
user_id=userId, app_id=app.id
).first()
app_roles.append( app_roles.append(
{ {
"name": app.slug, "name": app.slug,