ynput/ayon-backend

Deploy project: optimize default access group assignment

Closed this issue · 0 comments

Story

in ayon_selver.helpers.deploy_project the way default access groups are assigned for a new project to users is highly unoptimized.
Function loads every UserEntity with at least one default access group and resaves each user.

Expected behavior

Use UPDATE users ..... RETURNING name to modify users.data on the SQL level and return a list of users affected by this update.
This list can be then used to update active sessions - since we won't have the UserEntity object at that point Session.update cannot be used and we need to patch each session manually, but it would significantly reduce DB load.

from number_of_users * 2 to just one SQL query.

In order to speed up project deployment:

  • collect all active sessions
  • update sessions that needs updating using known keys

otherwise every non-manager will try to list all sessions from redis, that is costly. consider caching active sessions during the request as well