-
Notifications
You must be signed in to change notification settings - Fork 119
Description
Please complete the following fields as applicable:
Expected behaviour:
The method Org#plans should only return plans of the current Org.
Actual behaviour:
It also returns plans of other orgs.
Besides, it generates very large queries, that are reexecuted every time someone uses org.plans
in his code. If I remove this method, and so use the more simple (and cached) relation plans,
the global page loading time goes from 4s to 40ms.
Reason: The relation plans in the model Org is defined,
but overridden a few lines further (https://github.com/DMPRoadmap/roadmap/blob/master/app/models/org.rb#L287).
But that last method is slow and does not work as expected.
How it works now:
- Select all roles with
active:true, access in set ofadministrative, anduser_idin list oforg.users.pluck(:id) - Pluck attribute
plan_id, make it unique, and store it inplan_ids - Fetch all plans with id in list of
plan_ids
Why it does not work: some users can have administrative rights to plans that actually belong to another organisation
Is this intended behaviour?
Steps to reproduce: