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

svn at pti.co.il svn at pti.co.il
Thu Jul 19 17:06:18 EEST 2007


Author: gabor
Date: 2007-07-19 17:06:18 +0300 (Thu, 19 Jul 2007)
New Revision: 261

Modified:
   trunk/
   trunk/bin/create_feed.pl
   trunk/lib/CPAN/Forum/DB/Groups.pm
   trunk/lib/CPAN/Forum/DB/Tags.pm
   trunk/lib/CPAN/Forum/DB/Users.pm
   trunk/templates/faq.tmpl
Log:
add dump of tags, tag_cloud, groups and users tables



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

Modified: trunk/bin/create_feed.pl
===================================================================
--- trunk/bin/create_feed.pl	2007-07-19 14:05:59 UTC (rev 260)
+++ trunk/bin/create_feed.pl	2007-07-19 14:06:18 UTC (rev 261)
@@ -11,6 +11,8 @@
 use CPAN::Forum::DBI;
 use CPAN::Forum::DB::Posts;
 use CPAN::Forum::DB::Tags;
+use CPAN::Forum::DB::Groups;
+use CPAN::Forum::DB::Users;
 
 my %opts;
 GetOptions(\%opts, 'help', 'dbdir=s', 'out=s') or usage();
@@ -61,8 +63,10 @@
     mkdir "$opts{out}/cpanforum";
     chdir "$opts{out}/cpanforum";
 
-    my $tags = CPAN::Forum::DB::Tags->dump_tags;
-    _save_file("tags.csv", $tags);
+    _save_file("tags.csv",      "id,name",            CPAN::Forum::DB::Tags->dump_tags);
+    _save_file("tag_cloud.csv", "uid,tag_id,dist_id", CPAN::Forum::DB::Tags->dump_tag_cloud);
+    _save_file("dists.csv",     "id,name",            CPAN::Forum::DB::Groups->dump_groups);
+    _save_file("users.csv",     "id,username",        CPAN::Forum::DB::Users->dump_users);
 
     chdir $cwd;
     chdir $opts{out};
@@ -70,9 +74,10 @@
 }
 
 sub _save_file {
-    my ($file, $ar) = @_;
+    my ($file, $header, $ar) = @_;
 
     open my $out, '>', $file or die "Could not open '$file': $!";
+    print $out "$header\n";
     foreach my $r (@$ar) {
         print $out join ",", @$r;
         print $out "\n";

Modified: trunk/lib/CPAN/Forum/DB/Groups.pm
===================================================================
--- trunk/lib/CPAN/Forum/DB/Groups.pm	2007-07-19 14:05:59 UTC (rev 260)
+++ trunk/lib/CPAN/Forum/DB/Groups.pm	2007-07-19 14:06:18 UTC (rev 261)
@@ -25,5 +25,11 @@
     return $self->_fetch_single_hashref($sql, $group_id);
 }
 
+sub dump_groups {
+    my ($self) = @_;
+    my $sql = "SELECT id, name FROM groups";
+    return $self->_dump($sql); 
+}
+
 1;
 

Modified: trunk/lib/CPAN/Forum/DB/Tags.pm
===================================================================
--- trunk/lib/CPAN/Forum/DB/Tags.pm	2007-07-19 14:05:59 UTC (rev 260)
+++ trunk/lib/CPAN/Forum/DB/Tags.pm	2007-07-19 14:06:18 UTC (rev 261)
@@ -132,6 +132,11 @@
     my $sql = "SELECT id, name FROM tags ORDER BY id";
     return $self->_dump($sql); 
 }
+sub dump_tag_cloud {
+    my ($self) = @_;
+    my $sql = "SELECT uid, tag_id, group_id FROM tag_cloud";
+    return $self->_dump($sql); 
+}
 
 =head1 Design
 

Modified: trunk/lib/CPAN/Forum/DB/Users.pm
===================================================================
--- trunk/lib/CPAN/Forum/DB/Users.pm	2007-07-19 14:05:59 UTC (rev 260)
+++ trunk/lib/CPAN/Forum/DB/Users.pm	2007-07-19 14:06:18 UTC (rev 261)
@@ -47,6 +47,12 @@
     return $self->_fetch_single_hashref($sql, $user_id);
 }
 
+sub dump_users {
+    my ($self) = @_;
+    my $sql = "SELECT id, username FROM users";
+    return $self->_dump($sql); 
+}
 
+
 1;
 

Modified: trunk/templates/faq.tmpl
===================================================================
--- trunk/templates/faq.tmpl	2007-07-19 14:05:59 UTC (rev 260)
+++ trunk/templates/faq.tmpl	2007-07-19 14:06:18 UTC (rev 261)
@@ -153,9 +153,9 @@
   <br />
   <a href="/cpanforum.csv">Number of posts per module</a> In format: <i>Module,42</i>
   <br />
-  <a href="/module_tags.csv.bz2">List of tags on each module</a>In format: <i>Module,tag1,tag2,tag3</i>
+  <a href="/module_tags.csv.bz2">List of tags on each module</a> In format: <i>Module,tag1,tag2,tag3</i>
   <br />
-  <a href="/db_dump.tar.bz2">Partial dump of the database</a>For now mainly the tables related to tags
+  <a href="/db_dump.tar.bz2">Partial dump of the database</a>, mainly the tables related to tags.
  </dd>
 </dl>
 </div>



More information about the Cpan-forum-commit mailing list