Skip to content
12 changes: 7 additions & 5 deletions app/models/org.rb
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,13 @@ def org_admins
end

def plans
plan_ids = Role.administrator
.where(user_id: users.pluck(:id), active: true)
.pluck(:plan_id).uniq
Plan.includes(:template, :phases, :roles, :users)
.where(id: plan_ids)
Rails.cache.fetch("org[#{id}].plans", expires_in: 2.seconds) do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I think this approach can be useful elsewhere as well.

plan_ids = Role.administrator
.where(user_id: users.pluck(:id), active: true)
.pluck(:plan_id).uniq
Plan.includes(:template, :phases, :roles, :users)
.where(id: plan_ids)
end
end

def grant_api!(token_permission_type)
Expand Down