Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/services/groups')
-rw-r--r--app/services/groups/autocomplete_service.rb49
-rw-r--r--app/services/groups/count_service.rb23
-rw-r--r--app/services/groups/create_service.rb4
-rw-r--r--app/services/groups/destroy_service.rb2
-rw-r--r--app/services/groups/import_export/export_service.rb4
-rw-r--r--app/services/groups/import_export/import_service.rb4
-rw-r--r--app/services/groups/open_issues_count_service.rb15
-rw-r--r--app/services/groups/participants_service.rb31
-rw-r--r--app/services/groups/transfer_service.rb8
-rw-r--r--app/services/groups/update_service.rb2
10 files changed, 124 insertions, 18 deletions
diff --git a/app/services/groups/autocomplete_service.rb b/app/services/groups/autocomplete_service.rb
new file mode 100644
index 00000000000..92b05d9ac08
--- /dev/null
+++ b/app/services/groups/autocomplete_service.rb
@@ -0,0 +1,49 @@
+# frozen_string_literal: true
+
+module Groups
+ class AutocompleteService < Groups::BaseService
+ include LabelsAsHash
+
+ # rubocop: disable CodeReuse/ActiveRecord
+ def issues(confidential_only: false, issue_types: nil)
+ finder_params = { group_id: group.id, include_subgroups: true, state: 'opened' }
+ finder_params[:confidential] = true if confidential_only.present?
+ finder_params[:issue_types] = issue_types if issue_types.present?
+
+ IssuesFinder.new(current_user, finder_params)
+ .execute
+ .preload(project: :namespace)
+ .select(:iid, :title, :project_id)
+ end
+ # rubocop: enable CodeReuse/ActiveRecord
+
+ # rubocop: disable CodeReuse/ActiveRecord
+ def merge_requests
+ MergeRequestsFinder.new(current_user, group_id: group.id, include_subgroups: true, state: 'opened')
+ .execute
+ .preload(target_project: :namespace)
+ .select(:iid, :title, :target_project_id)
+ end
+ # rubocop: enable CodeReuse/ActiveRecord
+
+ # rubocop: disable CodeReuse/ActiveRecord
+ def milestones
+ group_ids = group.self_and_ancestors.public_or_visible_to_user(current_user).pluck(:id)
+
+ MilestonesFinder.new(group_ids: group_ids).execute.select(:iid, :title, :due_date)
+ end
+ # rubocop: enable CodeReuse/ActiveRecord
+
+ def labels_as_hash(target)
+ super(target, group_id: group.id, only_group_labels: true, include_ancestor_groups: true)
+ end
+
+ def commands(noteable)
+ return [] unless noteable
+
+ QuickActions::InterpretService.new(nil, current_user).available_commands(noteable)
+ end
+ end
+end
+
+Groups::AutocompleteService.prepend_mod
diff --git a/app/services/groups/count_service.rb b/app/services/groups/count_service.rb
index 2a15ae3bc57..735acddb025 100644
--- a/app/services/groups/count_service.rb
+++ b/app/services/groups/count_service.rb
@@ -19,13 +19,26 @@ module Groups
cached_count = Rails.cache.read(cache_key)
return cached_count unless cached_count.blank?
- refreshed_count = uncached_count
- update_cache_for_key(cache_key) { refreshed_count } if refreshed_count > CACHED_COUNT_THRESHOLD
- refreshed_count
+ refresh_cache_over_threshold
end
- def cache_key
- ['groups', "#{issuable_key}_count_service", VERSION, group.id, cache_key_name]
+ def refresh_cache_over_threshold(key = nil)
+ key ||= cache_key
+ new_count = uncached_count
+
+ if new_count > CACHED_COUNT_THRESHOLD
+ update_cache_for_key(key) { new_count }
+ else
+ delete_cache
+ end
+
+ new_count
+ end
+
+ def cache_key(key_name = nil)
+ key_name ||= cache_key_name
+
+ ['groups', "#{issuable_key}_count_service", VERSION, group.id, key_name]
end
private
diff --git a/app/services/groups/create_service.rb b/app/services/groups/create_service.rb
index 9ddb8ae7695..8e8efe7d555 100644
--- a/app/services/groups/create_service.rb
+++ b/app/services/groups/create_service.rb
@@ -37,7 +37,7 @@ module Groups
Group.transaction do
if @group.save
@group.add_owner(current_user)
- Service.create_from_active_default_integrations(@group, :group_id)
+ Integration.create_from_active_default_integrations(@group, :group_id)
OnboardingProgress.onboard(@group)
end
end
@@ -103,4 +103,4 @@ module Groups
end
end
-Groups::CreateService.prepend_if_ee('EE::Groups::CreateService')
+Groups::CreateService.prepend_mod_with('Groups::CreateService')
diff --git a/app/services/groups/destroy_service.rb b/app/services/groups/destroy_service.rb
index a27330d1104..08c4e0231e7 100644
--- a/app/services/groups/destroy_service.rb
+++ b/app/services/groups/destroy_service.rb
@@ -58,4 +58,4 @@ module Groups
end
end
-Groups::DestroyService.prepend_if_ee('EE::Groups::DestroyService')
+Groups::DestroyService.prepend_mod_with('Groups::DestroyService')
diff --git a/app/services/groups/import_export/export_service.rb b/app/services/groups/import_export/export_service.rb
index a436aec1b39..ea26ebec20b 100644
--- a/app/services/groups/import_export/export_service.rb
+++ b/app/services/groups/import_export/export_service.rb
@@ -96,7 +96,7 @@ module Groups
def notify_error!
notify_error
- raise Gitlab::ImportExport::Error.new(shared.errors.to_sentence)
+ raise Gitlab::ImportExport::Error, shared.errors.to_sentence
end
def notify_success
@@ -127,4 +127,4 @@ module Groups
end
end
-Groups::ImportExport::ExportService.prepend_if_ee('EE::Groups::ImportExport::ExportService')
+Groups::ImportExport::ExportService.prepend_mod_with('Groups::ImportExport::ExportService')
diff --git a/app/services/groups/import_export/import_service.rb b/app/services/groups/import_export/import_service.rb
index bf3f09f22d4..f9db552f743 100644
--- a/app/services/groups/import_export/import_service.rb
+++ b/app/services/groups/import_export/import_service.rb
@@ -114,7 +114,7 @@ module Groups
def notify_error!
notify_error
- raise Gitlab::ImportExport::Error.new(shared.errors.to_sentence)
+ raise Gitlab::ImportExport::Error, shared.errors.to_sentence
end
def remove_base_tmp_dir
@@ -124,4 +124,4 @@ module Groups
end
end
-Groups::ImportExport::ImportService.prepend_if_ee('EE::Groups::ImportExport::ImportService')
+Groups::ImportExport::ImportService.prepend_mod_with('Groups::ImportExport::ImportService')
diff --git a/app/services/groups/open_issues_count_service.rb b/app/services/groups/open_issues_count_service.rb
index ef787a04315..17cf3d38987 100644
--- a/app/services/groups/open_issues_count_service.rb
+++ b/app/services/groups/open_issues_count_service.rb
@@ -6,6 +6,12 @@ module Groups
PUBLIC_COUNT_KEY = 'group_public_open_issues_count'
TOTAL_COUNT_KEY = 'group_total_open_issues_count'
+ def clear_all_cache_keys
+ [cache_key(PUBLIC_COUNT_KEY), cache_key(TOTAL_COUNT_KEY)].each do |key|
+ Rails.cache.delete(key)
+ end
+ end
+
private
def cache_key_name
@@ -23,7 +29,14 @@ module Groups
end
def relation_for_count
- IssuesFinder.new(user, group_id: group.id, state: 'opened', non_archived: true, include_subgroups: true, public_only: public_only?).execute
+ IssuesFinder.new(
+ user,
+ group_id: group.id,
+ state: 'opened',
+ non_archived: true,
+ include_subgroups: true,
+ public_only: public_only?
+ ).execute
end
def issuable_key
diff --git a/app/services/groups/participants_service.rb b/app/services/groups/participants_service.rb
new file mode 100644
index 00000000000..0844c98dd6a
--- /dev/null
+++ b/app/services/groups/participants_service.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+module Groups
+ class ParticipantsService < Groups::BaseService
+ include Users::ParticipableService
+
+ def execute(noteable)
+ @noteable = noteable
+
+ participants =
+ noteable_owner +
+ participants_in_noteable +
+ all_members +
+ groups +
+ group_members
+
+ render_participants_as_hash(participants.uniq)
+ end
+
+ def all_members
+ count = group_members.count
+ [{ username: "all", name: "All Group Members", count: count }]
+ end
+
+ def group_members
+ return [] unless noteable
+
+ @group_members ||= sorted(noteable.group.direct_and_indirect_users)
+ end
+ end
+end
diff --git a/app/services/groups/transfer_service.rb b/app/services/groups/transfer_service.rb
index e800e546a45..56ff1310def 100644
--- a/app/services/groups/transfer_service.rb
+++ b/app/services/groups/transfer_service.rb
@@ -200,16 +200,16 @@ module Groups
end
def update_integrations
- @group.services.inherit.delete_all
- Service.create_from_active_default_integrations(@group, :group_id)
+ @group.integrations.inherit.delete_all
+ Integration.create_from_active_default_integrations(@group, :group_id)
end
def propagate_integrations
- @group.services.inherit.each do |integration|
+ @group.integrations.inherit.each do |integration|
PropagateIntegrationWorker.perform_async(integration.id)
end
end
end
end
-Groups::TransferService.prepend_if_ee('EE::Groups::TransferService')
+Groups::TransferService.prepend_mod_with('Groups::TransferService')
diff --git a/app/services/groups/update_service.rb b/app/services/groups/update_service.rb
index ff369d01efc..1ad43b051be 100644
--- a/app/services/groups/update_service.rb
+++ b/app/services/groups/update_service.rb
@@ -147,4 +147,4 @@ module Groups
end
end
-Groups::UpdateService.prepend_if_ee('EE::Groups::UpdateService')
+Groups::UpdateService.prepend_mod_with('Groups::UpdateService')