From 09f1d2e00a7ba1b368890ce0366817cfd04142d2 Mon Sep 17 00:00:00 2001 From: Luka Radenovic Date: Mon, 16 May 2022 14:01:56 +0200 Subject: [PATCH] Optimize insert app role to user --- areas/users/user_service.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/areas/users/user_service.py b/areas/users/user_service.py index 70ce78c..c75185d 100644 --- a/areas/users/user_service.py +++ b/areas/users/user_service.py @@ -81,13 +81,12 @@ class UserService: @staticmethod def __insertAppRoleToUser(userId, userRes): - app_role = AppRole.query.filter_by(user_id=userId) apps = App.query.all() - app_roles = [] - 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( { "name": app.slug,