17040: Cache results of User.group_permissions
authorPeter Amstutz <peter.amstutz@curii.com>
Mon, 2 Nov 2020 21:20:02 +0000 (16:20 -0500)
committerPeter Amstutz <peter.amstutz@curii.com>
Thu, 5 Nov 2020 20:16:35 +0000 (15:16 -0500)
commita9b64985f573edb9a3a360afc245e32175faa5cc
tree68124b67f1415a02de78d976056bb27f57c9b897
parentb2c7e3d09f2ee51ca1938c397f29e8627840e61e
17040: Cache results of User.group_permissions

When requesting a list of groups (either directly, or with the
"shared" endpoint) it calls writable_by for each group.  This
indirectly calls User.group_permissions, which makes a database query.
When it does this for every group (with a database query each time),
which gets very expensive.

To address this, this commit caches the result of group_permissions on
the user object.

Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz@curii.com>
services/api/app/models/link.rb
services/api/app/models/user.rb
services/api/lib/current_api_client.rb
services/api/test/test_helper.rb