Андрей (andy) wrote in changelog,
Андрей
andy
changelog

[livejournal] r22999: LJSUP-13770 (refactor LJ FAQs from BML t...

Committer: ailyin
LJSUP-13770 (refactor LJ FAQs from BML to controllers)
U   branches/faq-refactor/cgi-bin/LJ/Faq.pm
Modified: branches/faq-refactor/cgi-bin/LJ/Faq.pm
===================================================================
--- branches/faq-refactor/cgi-bin/LJ/Faq.pm	2012-09-28 08:42:47 UTC (rev 22998)
+++ branches/faq-refactor/cgi-bin/LJ/Faq.pm	2012-09-28 09:11:04 UTC (rev 22999)
@@ -470,34 +470,34 @@
         or die "initial FAQ rendering failed";
 
     foreach my $f (@faqs) {
-	my $score = 0;
+        my $score = 0;
 
-	if ($f->question_raw =~ /\Q$term\E/i) {
-	    $score += 3;
-	}
-	if ($f->question_raw =~ /\b\Q$term\E\b/i) {
-	    $score += 5;
-	}
+        if ($f->question_raw =~ /\Q$term\E/i) {
+            $score += 3;
+        }
+        if ($f->question_raw =~ /\b\Q$term\E\b/i) {
+            $score += 5;
+        }
 
-	if ($f->summary_raw =~ /\Q$term\E/i) {
-	    $score += 2;
-	}
-	if ($f->summary_raw =~ /\b\Q$term\E\b/i) {
-	    $score += 4;
-	}
+        if ($f->summary_raw =~ /\Q$term\E/i) {
+            $score += 2;
+        }
+        if ($f->summary_raw =~ /\b\Q$term\E\b/i) {
+            $score += 4;
+        }
 
-	if ($f->answer_raw =~ /\Q$term\E/i) {
-	    $score += 1;
-	}
-	if ($f->answer_raw =~ /\b\Q$term\E\b/i) {
-	    $score += 3;
-	}
+        if ($f->answer_raw =~ /\Q$term\E/i) {
+            $score += 1;
+        }
+        if ($f->answer_raw =~ /\b\Q$term\E\b/i) {
+            $score += 3;
+        }
 
-	next unless $score;
+        next unless $score;
 
-	$scores{$f->{faqid}} = $score;
+        $scores{$f->{faqid}} = $score;
 
-	push @results, $f;
+        push @results, $f;
     }
 
     return sort { $scores{$b->{faqid}} <=> $scores{$a->{faqid}} } @results;
@@ -506,6 +506,8 @@
 sub note_usage {
     my ( $self, $remote ) = @_;
 
+    return unless $remote && LJ::is_enabled('faquses');
+
     my $dbh = LJ::get_db_writer();
     $dbh->do(
         'REPLACE INTO faquses SET faqid=?, userid=?, dateview=NOW()',

Tags: ailyin, andy, livejournal, pm
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments