-
Arturo Herrero authored
Remove unnecessary validation avoiding N+1 queries when building integrations. This is a follow-up to fix https://gitlab.com/gitlab-org/gitlab/-/issues/326209 where find or initialize services causes N+1 queries. Find or initialize the services has the following precedence: - Find existing records. - Build services from instance-level record or service template record. => This commit fixes the N+1 here. - Build services from scratch. Fixed https://gitlab.com/gitlab-org/gitlab/-/merge_requests/58879. In this case, when building one integration from an instance-level integration or service template we check for service.invalid? which triggers a query. service is an in-memory object but it checks the uniqueness by type and project. We can remove this because it's redundant: - All the integration records should be valid, we worked to verified that https://gitlab.com/groups/gitlab-org/-/epics/3366. - build_from_integration copy the active value from the instance-level or service template. So if that integration is inactive, service = integration.dup will copy active attribute as false.
be4a1dac