[Cpan-forum-commit] rev 179 - in trunk: . bin lib/CPAN/Forum

svn at pti.co.il svn at pti.co.il
Sat Aug 26 19:48:02 IDT 2006


Author: gabor
Date: 2006-08-26 19:48:02 +0300 (Sat, 26 Aug 2006)
New Revision: 179

Added:
   trunk/bin/create_feed.pl
Modified:
   trunk/
   trunk/Changes
   trunk/TODO
   trunk/bin/populate.pl
   trunk/lib/CPAN/Forum/Posts.pm
Log:
Provide a csv file with the number of posts for each distribution so 
  other sites can include it.




Property changes on: trunk
___________________________________________________________________
Name: svk:merge
   - 8c4c90e1-83eb-0310-96eb-e7cb62807872:/local/cpan-forum:11023
   + 8c4c90e1-83eb-0310-96eb-e7cb62807872:/local/cpan-forum:11024

Modified: trunk/Changes
===================================================================
--- trunk/Changes	2006-08-26 16:47:57 UTC (rev 178)
+++ trunk/Changes	2006-08-26 16:48:02 UTC (rev 179)
@@ -1,6 +1,9 @@
 
 v0.12 
 
+  Provide a csv file with the number of posts for each distribution so 
+  other sites can include it.
+
   Logging: add client IP to logger to enable filtering log messages based on that 
 
   Clean up STDERR, move (some) voluntary warnings to logger

Modified: trunk/TODO
===================================================================
--- trunk/TODO	2006-08-26 16:47:57 UTC (rev 178)
+++ trunk/TODO	2006-08-26 16:48:02 UTC (rev 179)
@@ -1,8 +1,15 @@
 
   Tests  *  Tests   *   Tests
 
+  Missing entries: 
+    ApacheDBI
+    Net-SMS-TWSMS   missing from 02... and from CPANTS
+  they are both on search.cpan.org
 
+  Improve the populate.pl, look at CPANTS for ideas:
+  http://search.cpan.org/src/DOMM/Module-CPANTS-ProcessCPAN-0.62/bin/update_authors.pl
 
+
   Cleanup the schema. Currently the schema/schema.sql is not the same as the
   schema used in the live application.
 
@@ -29,11 +36,8 @@
 
   Include number of AnnoCPAN posts
   
-  Provide a csv file with the number of posts for each distribution so 
-  other sites can include it.
 
 
-
 BUG:
 When I try to reply and the original subject is already 50 chars long
 in offers a new subject with Re: prefix but then when I try to submit

Added: trunk/bin/create_feed.pl
===================================================================
--- trunk/bin/create_feed.pl	2006-08-26 16:47:57 UTC (rev 178)
+++ trunk/bin/create_feed.pl	2006-08-26 16:48:02 UTC (rev 179)
@@ -0,0 +1,51 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+use Getopt::Long qw(GetOptions);
+use Text::CSV_XS;
+
+use lib "lib";
+
+use CPAN::Forum::DBI;
+use CPAN::Forum::Posts;
+
+my %opts;
+GetOptions(\%opts, 'help', 'dir=s', 'csv=s') or usage();
+usage() if $opts{help};
+usage() if not $opts{dir} or not $opts{csv};
+
+
+my $dbfile       = "$opts{dir}/forum.db";
+CPAN::Forum::DBI->myinit("dbi:SQLite:$dbfile");
+
+my $csv          = Text::CSV_XS->new();
+
+;
+open my $out, '>', $opts{csv} or die $!;
+foreach my $entry (CPAN::Forum::Posts->search_stat_posts) {
+    if ($csv->combine($entry->{gname}, $entry->{cnt})) {
+        print {$out} $csv->string(), "\n";
+    } else {
+        warn "Invalid row";
+    }
+}
+
+
+
+
+sub usage {
+
+    print <<"END_USAGE";
+
+Usage: $0
+        --help             this help
+        --dir  DIR         directory of forum.db file
+        --csv  FILENAME    path to the output csv file
+END_USAGE
+    exit;
+}
+
+
+
+

Modified: trunk/bin/populate.pl
===================================================================
--- trunk/bin/populate.pl	2006-08-26 16:47:57 UTC (rev 178)
+++ trunk/bin/populate.pl	2006-08-26 16:48:02 UTC (rev 179)
@@ -23,19 +23,7 @@
 usage() if $opts{help};
 usage() if not $opts{dir};
 
-sub usage {
-    print <<"END_USAGE";
-$0
-    --sendmail      to send report to Gabor
-    --source FILE   path to the 02packages.details.txt
-    --dir DIR       directory of the database
-    --fetch
-    --help          this help
-END_USAGE
-    exit;
-}
 
-
 my $dbfile       = "$opts{dir}/forum.db";
 CPAN::Forum::DBI->myinit("dbi:SQLite:$dbfile");
 
@@ -188,4 +176,16 @@
 }
 
 
+sub usage {
+    print <<"END_USAGE";
+$0
+    --sendmail      to send report to Gabor
+    --source FILE   path to the 02packages.details.txt
+    --dir DIR       directory of the database
+    --fetch
+    --help          this help
+END_USAGE
+    exit;
+}
 
+

Modified: trunk/lib/CPAN/Forum/Posts.pm
===================================================================
--- trunk/lib/CPAN/Forum/Posts.pm	2006-08-26 16:47:57 UTC (rev 178)
+++ trunk/lib/CPAN/Forum/Posts.pm	2006-08-26 16:48:02 UTC (rev 179)
@@ -23,6 +23,13 @@
                             FROM groups, authors
                             WHERE groups.pauseid=authors.id and authors.pauseid=?)
                         ORDER BY date DESC});
+__PACKAGE__->set_sql(stat_posts => qq{
+            SELECT COUNT(*) cnt, groups.name gname
+            FROM posts,groups 
+            WHERE posts.gid=groups.id 
+            GROUP BY gname
+            ORDER BY cnt DESC
+            });
 
 sub retrieve_latest { 
     my ($class, $count) = @_;



More information about the Cpan-forum-commit mailing list