diff --git a/app/lib/check_elastic_search.rb b/app/lib/check_elastic_search.rb index 00cb5681ab..35268006bb 100644 --- a/app/lib/check_elastic_search.rb +++ b/app/lib/check_elastic_search.rb @@ -82,6 +82,7 @@ def get_fresh_value(data) def add_update_nested_obj(options) return if self.disable_es_callbacks || RequestStore.store[:disable_es_callbacks] + return if options[:op] == 'create' && self.respond_to?(:hit_nested_objects_limit?) && self.hit_nested_objects_limit? model = { klass: self.class.name, id: self.id } ElasticSearchWorker.perform_in(1.second, YAML::dump(model), YAML::dump(options), 'create_update_doc_nested') end diff --git a/app/models/concerns/annotation_base.rb b/app/models/concerns/annotation_base.rb index 20636fbc0d..ad3cebb944 100644 --- a/app/models/concerns/annotation_base.rb +++ b/app/models/concerns/annotation_base.rb @@ -156,6 +156,13 @@ def custom_permissions(ability = nil) perms["destroy Smooch"] = ability.can?(:destroy, self) if self.annotation_type == 'smooch' perms end + + def hit_nested_objects_limit? + ret = false + pm = self.project_media + ret = pm.get_annotations(self.annotation_type).count > CheckConfig.get('nested_objects_limit', 10000, :integer) unless pm.nil? + ret + end end module ClassMethods diff --git a/app/models/tipline_request.rb b/app/models/tipline_request.rb index 385f64d258..ad0fb75147 100644 --- a/app/models/tipline_request.rb +++ b/app/models/tipline_request.rb @@ -64,6 +64,11 @@ def associated_graphql_id Base64.encode64("#{self.associated_type}/#{self.associated_id}") end + def hit_nested_objects_limit? + associated = self.associated + associated.tipline_requests.count > CheckConfig.get('nested_objects_limit', 10000, :integer) + end + private def set_team_and_user