diff --git a/app/models/annotations/tag.rb b/app/models/annotations/tag.rb index d365976f0..4755b39d6 100644 --- a/app/models/annotations/tag.rb +++ b/app/models/annotations/tag.rb @@ -84,6 +84,13 @@ def self.run_bulk_create_callbacks(ids_json, pmids_json) ProjectMedia.where(id: pmids).find_each { |pm| pm.tags_as_sentence } 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 + private def get_tag_text_reference diff --git a/app/models/concerns/annotation_base.rb b/app/models/concerns/annotation_base.rb index ad3cebb94..20636fbc0 100644 --- a/app/models/concerns/annotation_base.rb +++ b/app/models/concerns/annotation_base.rb @@ -156,13 +156,6 @@ 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/test/controllers/elastic_search_7_test.rb b/test/controllers/elastic_search_7_test.rb index a10d4dee8..dca282fad 100644 --- a/test/controllers/elastic_search_7_test.rb +++ b/test/controllers/elastic_search_7_test.rb @@ -300,29 +300,5 @@ def setup end end - test "should ignore index task responses that exceeds nested objects limit" do - team = create_team - stub_configs({ 'nested_objects_limit' => 2 }) do - tt = create_team_task team_id: team.id, type: 'single_choice', options: ['ans_a', 'ans_b', 'ans_c'] - tt2 = create_team_task team_id: team.id, type: 'single_choice', options: ['ans_aa', 'ans_bb', 'ans_cc'] - tt3 = create_team_task team_id: team.id, type: 'free_text' - pm = create_project_media team: team, disable_es_callbacks: false - pm_tt = pm.annotations('task').select{|t| t.team_task_id == tt.id}.last - pm_tt.response = { annotation_type: 'task_response_single_choice', set_fields: { response_single_choice: 'ans_a' }.to_json }.to_json - pm_tt.save! - pm_tt2 = pm.annotations('task').select{|t| t.team_task_id == tt2.id}.last - pm_tt2.response = { annotation_type: 'task_response_single_choice', set_fields: { response_single_choice: 'ans_aa' }.to_json }.to_json - pm_tt2.save! - pm_tt3 = pm.annotations('task').select{|t| t.team_task_id == tt3.id}.last - pm_tt3.response = { annotation_type: 'task_response_free_text', set_fields: { response_free_text: 'Foo by Sawy' }.to_json }.to_json - pm_tt3.save! - sleep 2 - es = $repository.find(pm.get_es_doc_id) - task_responses = es['task_responses'] - # TODO: fix the test - # assert_equal 2, task_responses.size - end - end - # Please add new tests to test/controllers/elastic_search_8_test.rb end diff --git a/test/controllers/elastic_search_9_test.rb b/test/controllers/elastic_search_9_test.rb index 3f14d8f21..6493472a9 100644 --- a/test/controllers/elastic_search_9_test.rb +++ b/test/controllers/elastic_search_9_test.rb @@ -240,9 +240,6 @@ def setup t = create_tag annotated: pm, disable_es_callbacks: false t2 = create_tag annotated: pm, disable_es_callbacks: false t3 = create_tag annotated: pm, disable_es_callbacks: false - c = create_comment annotated: pm, disable_es_callbacks: false - c2 = create_comment annotated: pm, disable_es_callbacks: false - c3 = create_comment annotated: pm, disable_es_callbacks: false sleep 2 es = $repository.find(pm.get_es_doc_id) requests = es['requests'] @@ -251,9 +248,6 @@ def setup tags = es['tags'] assert_equal 2, tags.size assert_equal [t.id, t2.id], tags.collect{|i| i['id']}.sort - comments = es['comments'] - assert_equal 2, comments.size - assert_equal [c.id, c2.id], comments.collect{|i| i['id']}.sort end end