diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-16 15:09:26 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-16 15:09:26 +0300 |
commit | b019dc959ec16b15fe42a680dbd729542ff61537 (patch) | |
tree | cde5c3d0582bd7542e1e195d83ad7a50079f4e49 /app/finders | |
parent | b7b44de429911864686599ef1643baf525bf75ec (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/finders')
-rw-r--r-- | app/finders/crm/contacts_finder.rb | 12 | ||||
-rw-r--r-- | app/finders/crm/organizations_finder.rb | 12 |
2 files changed, 24 insertions, 0 deletions
diff --git a/app/finders/crm/contacts_finder.rb b/app/finders/crm/contacts_finder.rb index f7c2625f788..29f3d6f0f16 100644 --- a/app/finders/crm/contacts_finder.rb +++ b/app/finders/crm/contacts_finder.rb @@ -8,6 +8,7 @@ # group: Group, required # search: String, optional # state: CustomerRelations::ContactStateEnum, optional +# ids: int[], optional module Crm class ContactsFinder include Gitlab::Allowable @@ -24,6 +25,7 @@ module Crm return CustomerRelations::Contact.none unless root_group contacts = root_group.contacts + contacts = by_ids(contacts) contacts = by_state(contacts) contacts = by_search(contacts) contacts.sort_by_name @@ -53,6 +55,12 @@ module Crm contacts.search_by_state(params[:state]) end + def by_ids(contacts) + return contacts unless ids? + + contacts.id_in(params[:ids]) + end + def search? params[:search].present? end @@ -60,5 +68,9 @@ module Crm def state? params[:state].present? end + + def ids? + params[:ids].present? + end end end diff --git a/app/finders/crm/organizations_finder.rb b/app/finders/crm/organizations_finder.rb index 1a3df05aa11..5a8ab148ef3 100644 --- a/app/finders/crm/organizations_finder.rb +++ b/app/finders/crm/organizations_finder.rb @@ -8,6 +8,7 @@ # group: Group, required # search: String, optional # state: CustomerRelations::OrganizationStateEnum, optional +# ids: int[], optional module Crm class OrganizationsFinder include Gitlab::Allowable @@ -24,6 +25,7 @@ module Crm return CustomerRelations::Organization.none unless root_group organizations = root_group.organizations + organizations = by_ids(organizations) organizations = by_search(organizations) organizations = by_state(organizations) organizations.sort_by_name @@ -53,6 +55,12 @@ module Crm organizations.search_by_state(params[:state]) end + def by_ids(organizations) + return organizations unless ids? + + organizations.id_in(params[:ids]) + end + def search? params[:search].present? end @@ -60,5 +68,9 @@ module Crm def state? params[:state].present? end + + def ids? + params[:ids].present? + end end end |