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>
Mon, 2 Nov 2020 21:20:02 +0000 (16:20 -0500)
commit13fa7a29e911e4c0e2a73375e8d312c9b54da8c2
treebabfd6a6a5f80a9ae72f9f9f8ec05471f61f214f
parent293163eff8dffab007b0a420f2cc8e0a795ceb50
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