Skip to content

Commit

Permalink
Fix rubocop offenses
Browse files Browse the repository at this point in the history
  • Loading branch information
malchua committed Dec 12, 2024
1 parent 6757d18 commit bf00830
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions app/models/group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,22 @@ def shared_namespace_metadata_keys(namespace)
metadata_fields
end

def aggregated_samples_count
def aggregated_samples_count # rubocop:disable Metrics/AbcSize
aggregated_samples_count = samples_count

return aggregated_samples_count unless shared_namespaces.any?

shared_projects_ids = []
shared_groups.self_and_descendants.where(type: [Namespaces::ProjectNamespace.sti_name]).where.not(id: self_and_descendants_of_type([Namespaces::ProjectNamespace.sti_name]).ids).each do |shared_project_namespace|
aggregated_samples_count += shared_project_namespace.project.samples.size
shared_projects_ids.push(shared_project_namespace.id)
projects_ids = []
shared_groups.self_and_descendants.where(type: [Namespaces::ProjectNamespace.sti_name])
.where.not(id: self_and_descendants_of_type([Namespaces::ProjectNamespace.sti_name]).ids)
.find_each do |project_namespace|
aggregated_samples_count += project_namespace.project.samples.size
projects_ids.push(project_namespace.id)
end

shared_project_namespaces.where.not(id: self_and_descendants_of_type([Namespaces::ProjectNamespace.sti_name]).ids).each do |shared_project_namespace|
aggregated_samples_count += shared_project_namespace.project.samples.size if not shared_projects_ids.include?(shared_project_namespace.id)
shared_project_namespaces.where.not(id: self_and_descendants_of_type([Namespaces::ProjectNamespace.sti_name]).ids)
.find_each do |project_namespace|
aggregated_samples_count += project_namespace.project.samples.size if projects_ids.exclude?(project_namespace.id)
end
aggregated_samples_count
end
Expand Down

0 comments on commit bf00830

Please sign in to comment.