From 3ea38b574915e3f8150d6dd10920b4d127070c75 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 8 Aug 2014 15:06:37 +1000 Subject: [PATCH] PERF: safeguard to ensure similarity search does not fire too much --- .../javascripts/discourse/controllers/composer.js.es6 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/assets/javascripts/discourse/controllers/composer.js.es6 b/app/assets/javascripts/discourse/controllers/composer.js.es6 index d0f4c6e5cb5..305d610b029 100644 --- a/app/assets/javascripts/discourse/controllers/composer.js.es6 +++ b/app/assets/javascripts/discourse/controllers/composer.js.es6 @@ -223,6 +223,13 @@ export default Discourse.Controller.extend({ if (body.length < Discourse.SiteSettings.min_body_similar_length || title.length < Discourse.SiteSettings.min_title_similar_length) { return; } + // TODO pass the 200 in from somewhere + body = body.substr(0, 200); + + // Done search over and over + if((title + body) === this.get('lastSimilaritySearch')) { return; } + this.set('lastSimilaritySearch', title + body); + var messageController = this.get('controllers.composer-messages'), similarTopics = this.get('similarTopics');