[Cpan-forum-commit] rev 264 - in trunk: . lib/CPAN lib/CPAN/Forum/DB lib/CPAN/Forum/RM

svn at pti.co.il svn at pti.co.il
Thu Jul 19 17:07:00 EEST 2007


Author: gabor
Date: 2007-07-19 17:07:00 +0300 (Thu, 19 Jul 2007)
New Revision: 264

Modified:
   trunk/
   trunk/lib/CPAN/Forum.pm
   trunk/lib/CPAN/Forum/DB/Posts.pm
   trunk/lib/CPAN/Forum/RM/Notify.pm
Log:
count thread to be plain SQL



Property changes on: trunk
___________________________________________________________________
Name: svk:merge
   - 7bc34947-122d-0410-bc5a-f898d2bb5f81:/local/cpan-forum:4230
8c4c90e1-83eb-0310-96eb-e7cb62807872:/local/cpan-forum:12752
   + 7bc34947-122d-0410-bc5a-f898d2bb5f81:/local/cpan-forum:4231
8c4c90e1-83eb-0310-96eb-e7cb62807872:/local/cpan-forum:12752

Modified: trunk/lib/CPAN/Forum/DB/Posts.pm
===================================================================
--- trunk/lib/CPAN/Forum/DB/Posts.pm	2007-07-19 14:06:45 UTC (rev 263)
+++ trunk/lib/CPAN/Forum/DB/Posts.pm	2007-07-19 14:07:00 UTC (rev 264)
@@ -13,7 +13,7 @@
 
 __PACKAGE__->set_sql(latest         => "SELECT __ESSENTIAL__ FROM __TABLE__ ORDER BY DATE DESC LIMIT %s");
 
-__PACKAGE__->set_sql(count_thread   => "SELECT count(*) FROM __TABLE__ WHERE thread=%s");
+#__PACKAGE__->set_sql(count_thread   => "SELECT count(*) FROM __TABLE__ WHERE thread=%s");
 __PACKAGE__->set_sql(count_where    => "SELECT count(*) FROM __TABLE__ WHERE %s='%s'");
 __PACKAGE__->set_sql(count_like     => "SELECT count(*) FROM __TABLE__ WHERE %s LIKE '%s'");
 #__PACKAGE__->add_constraint('subject_too_long', subject => sub { length $_[0] <= 70 and $_[0] !~ /</});
@@ -135,6 +135,11 @@
                ORDER BY cnt DESC";
     return $self->_fetch_arrayref_of_hashes($sql);
 }
+sub count_threads {
+    my ($self, $thread_id) = @_;
+    my $sql = "SELECT count(*) FROM posts WHERE thread=?";
+    return $self->_fetch_single_value($sql, $thread_id);
+}
 
 1;
  

Modified: trunk/lib/CPAN/Forum/RM/Notify.pm
===================================================================
--- trunk/lib/CPAN/Forum/RM/Notify.pm	2007-07-19 14:06:45 UTC (rev 263)
+++ trunk/lib/CPAN/Forum/RM/Notify.pm	2007-07-19 14:07:00 UTC (rev 264)
@@ -116,12 +116,12 @@
     my $call = "_generate_$type";
 
     my @params = @{$self->param("path_parameters")};
-    my $type;
+    my $content;
     if ($params[0] eq 'tags') {
-        $type = 'tags';
+        $content = 'tags';
     }
 
-    return $self->$call($url, $it, $type);
+    return $self->$call($url, $it, $content);
 }
 
 sub _generate_atom {

Modified: trunk/lib/CPAN/Forum.pm
===================================================================
--- trunk/lib/CPAN/Forum.pm	2007-07-19 14:06:45 UTC (rev 263)
+++ trunk/lib/CPAN/Forum.pm	2007-07-19 14:07:00 UTC (rev 264)
@@ -728,7 +728,8 @@
     
     my @resp;
     foreach my $post (@$it) {
-        my $thread_count = CPAN::Forum::DB::Posts->sql_count_thread($post->thread)->select_val;
+#warn "called too many times";
+        my $thread_count = CPAN::Forum::DB::Posts->count_threads($post->thread);
         push @resp, {
             subject      => _subject_escape($post->subject), 
             id           => $post->id, 
@@ -1068,7 +1069,7 @@
                 "PATH_INFO: $ENV{PATH_INFO}",
                 );
         }
-        my $thread_count = CPAN::Forum::DB::Posts->sql_count_thread($post->thread)->select_val;
+        my $thread_count = CPAN::Forum::DB::Posts->count_threads($post->thread);
         if ($thread_count > 1) {
             $t->param(thread_id    => $post->thread);
             $t->param(thread_count => $thread_count);



More information about the Cpan-forum-commit mailing list