Commit 92de19ba authored by allison.browne's avatar allison.browne

Remove join through projects

parent 0be78245
......@@ -435,7 +435,6 @@ class Project < ApplicationRecord
scope :with_merge_requests_available_for_user, ->(current_user) { with_feature_available_for_user(:merge_requests, current_user) }
scope :with_merge_requests_enabled, -> { with_feature_enabled(:merge_requests) }
scope :with_remote_mirrors, -> { joins(:remote_mirrors).where(remote_mirrors: { enabled: true }).distinct }
scope :with_grafana_integration_enabled, -> { joins(:grafana_integration).where(grafana_integrations: { enabled: true }) }
scope :with_group_runners_enabled, -> do
joins(:ci_cd_settings)
......
......@@ -5,9 +5,9 @@ module Gitlab
class << self
def issue_count
# rubocop:disable CodeReuse/ActiveRecord
Issue.joins(project: :grafana_integration)
.merge(Project.with_grafana_integration_enabled)
Issue.joins('JOIN grafana_integrations USING (project_id)')
.where("issues.description LIKE '%' || grafana_integrations.grafana_url || '%'")
.where(grafana_integrations: { enabled: true })
.count
# rubocop:enable CodeReuse/ActiveRecord
end
......
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