PERF: safeguard to ensure similarity search does not fire too much

This commit is contained in:
Sam 2014-08-08 15:06:37 +10:00
parent 16b7004767
commit 3ea38b5749
1 changed files with 7 additions and 0 deletions

View File

@ -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');