Commit 768aaefc authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch '238161-improve-cop-for-some-disabled-columns' into 'master'

Improve DistinctCountByLargeForeignKey cop

See merge request gitlab-org/gitlab!42188
parents 1b9578a5 91cb510d
......@@ -815,11 +815,9 @@ module Gitlab
end
# rubocop: disable CodeReuse/ActiveRecord
# rubocop: disable UsageData/DistinctCountByLargeForeignKey
def cluster_applications_user_distinct_count(applications, time_period)
distinct_count(applications.where(time_period).available.joins(:cluster), 'clusters.user_id')
end
# rubocop: enable UsageData/DistinctCountByLargeForeignKey
def clusters_user_distinct_count(clusters, time_period)
distinct_count(clusters.where(time_period), :user_id)
......
......@@ -31,11 +31,11 @@ module RuboCop
private
def allowed_foreign_key?(key)
[:sym, :str].include?(key.type) && allowed_foreign_keys.include?(key.value.to_sym)
[:sym, :str].include?(key.type) && allowed_foreign_keys.include?(key.value.to_s)
end
def allowed_foreign_keys
cop_config['AllowedForeignKeys'] || []
(cop_config['AllowedForeignKeys'] || []).map(&:to_s)
end
end
end
......
......@@ -38,12 +38,13 @@ UsageData/DistinctCountByLargeForeignKey:
- 'lib/gitlab/usage_data.rb'
- 'ee/lib/ee/gitlab/usage_data.rb'
AllowedForeignKeys:
- :user_id
- :author_id
- :creator_id
- :owner_id
- :project_id
- :issue_id
- :merge_request_id
- :merge_requests.target_project_id
- :agent_id
- 'agent_id'
- 'author_id'
- 'clusters.user_id'
- 'creator_id'
- 'issue_id'
- 'merge_request_id'
- 'merge_requests.target_project_id'
- 'owner_id'
- 'project_id'
- 'user_id'
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