Commit 8242c100 authored by Alper Akgun's avatar Alper Akgun

Fix gitlab_subscriptions N+1 query

parent 263ab502
...@@ -34,6 +34,7 @@ module EE ...@@ -34,6 +34,7 @@ module EE
accepts_nested_attributes_for :gitlab_subscription accepts_nested_attributes_for :gitlab_subscription
scope :include_gitlab_subscription, -> { includes(:gitlab_subscription) }
scope :with_plan, -> { where.not(plan_id: nil) } scope :with_plan, -> { where.not(plan_id: nil) }
scope :with_shared_runners_minutes_limit, -> { where("namespaces.shared_runners_minutes_limit > 0") } scope :with_shared_runners_minutes_limit, -> { where("namespaces.shared_runners_minutes_limit > 0") }
scope :with_extra_shared_runners_minutes_limit, -> { where("namespaces.extra_shared_runners_minutes_limit > 0") } scope :with_extra_shared_runners_minutes_limit, -> { where("namespaces.extra_shared_runners_minutes_limit > 0") }
......
...@@ -32,6 +32,8 @@ module API ...@@ -32,6 +32,8 @@ module API
get do get do
namespaces = current_user.admin ? Namespace.all : current_user.namespaces namespaces = current_user.admin ? Namespace.all : current_user.namespaces
namespaces = namespaces.include_gitlab_subscription if Gitlab.ee?
namespaces = namespaces.search(params[:search]) if params[:search].present? namespaces = namespaces.search(params[:search]) if params[:search].present?
options = { with: Entities::Namespace, current_user: current_user } options = { with: Entities::Namespace, current_user: current_user }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment