From e33beacdea4936267aa9ba28db2a88a82eb99f9b Mon Sep 17 00:00:00 2001 From: Rolf Schmidt Date: Thu, 8 Oct 2015 10:42:13 +0200 Subject: [PATCH] Added function to rebuild article signature detection for all articles. --- lib/signature_detection.rb | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/lib/signature_detection.rb b/lib/signature_detection.rb index 435d21066..0667b3d8b 100644 --- a/lib/signature_detection.rb +++ b/lib/signature_detection.rb @@ -139,6 +139,7 @@ returns article = ticket.articles.first article_bodies.push article.body } + find_signature( article_bodies ) end @@ -157,14 +158,46 @@ returns def self.rebuild_all User.select('id').where(active: true).each {|local_user| + signature_detection = by_user_id(local_user.id) next if !signature_detection + user = User.find(local_user.id) next if user.preferences[:signature_detection] == signature_detection + user.preferences[:signature_detection] = signature_detection user.save } true end +=begin + +rebuild signature for all articles + + SignatureDetection.rebuild_all_articles + +returns + + true/false + +=end + + def self.rebuild_all_articles + + Ticket::Article.all.each {|article| + + user = User.find(article.created_by_id) + next if !user.preferences[:signature_detection] + + signature_line = find_signature_line(user.preferences[:signature_detection], article.body) + next if !signature_line + next if article.preferences[:signature_detection] == signature_line + + article.preferences[:signature_detection] = signature_line + article.save + } + true + end + end