[Cpan-forum-commit] rev 260 - in trunk: . bin lib/CPAN/Forum lib/CPAN/Forum/DB templates
svn at pti.co.il
svn at pti.co.il
Thu Jul 19 17:05:59 EEST 2007
Author: gabor
Date: 2007-07-19 17:05:59 +0300 (Thu, 19 Jul 2007)
New Revision: 260
Modified:
trunk/
trunk/bin/create_feed.pl
trunk/lib/CPAN/Forum/DB/Tags.pm
trunk/lib/CPAN/Forum/DBI.pm
trunk/templates/faq.tmpl
Log:
provide feed of the tags table in csv format
Property changes on: trunk
___________________________________________________________________
Name: svk:merge
- 7bc34947-122d-0410-bc5a-f898d2bb5f81:/local/cpan-forum:4226
8c4c90e1-83eb-0310-96eb-e7cb62807872:/local/cpan-forum:12752
+ 7bc34947-122d-0410-bc5a-f898d2bb5f81:/local/cpan-forum:4227
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:42 UTC (rev 259)
+++ trunk/bin/create_feed.pl 2007-07-19 14:05:59 UTC (rev 260)
@@ -4,6 +4,7 @@
use Getopt::Long qw(GetOptions);
use Text::CSV_XS;
+use Cwd qw(cwd);
use lib "lib";
@@ -22,6 +23,7 @@
posts_count_csv();
tags();
+db_dump();
exit;
sub posts_count_csv {
@@ -54,6 +56,29 @@
system "/bin/bzip2 -f $opts{out}/module_tags.csv";
}
+sub db_dump {
+ my $cwd = cwd;
+ mkdir "$opts{out}/cpanforum";
+ chdir "$opts{out}/cpanforum";
+
+ my $tags = CPAN::Forum::DB::Tags->dump_tags;
+ _save_file("tags.csv", $tags);
+
+ chdir $cwd;
+ chdir $opts{out};
+ system "/bin/tar cjf db_dump.tar.bz2 cpanforum";
+}
+
+sub _save_file {
+ my ($file, $ar) = @_;
+
+ open my $out, '>', $file or die "Could not open '$file': $!";
+ foreach my $r (@$ar) {
+ print $out join ",", @$r;
+ print $out "\n";
+ }
+}
+
sub usage {
print <<"END_USAGE";
Modified: trunk/lib/CPAN/Forum/DB/Tags.pm
===================================================================
--- trunk/lib/CPAN/Forum/DB/Tags.pm 2007-07-19 14:05:42 UTC (rev 259)
+++ trunk/lib/CPAN/Forum/DB/Tags.pm 2007-07-19 14:05:59 UTC (rev 260)
@@ -127,6 +127,12 @@
return $self->_fetch_arrayref_of_hashes($sql);
}
+sub dump_tags {
+ my ($self) = @_;
+ my $sql = "SELECT id, name FROM tags ORDER BY id";
+ return $self->_dump($sql);
+}
+
=head1 Design
Every person can put any tage on any module
Modified: trunk/lib/CPAN/Forum/DBI.pm
===================================================================
--- trunk/lib/CPAN/Forum/DBI.pm 2007-07-19 14:05:42 UTC (rev 259)
+++ trunk/lib/CPAN/Forum/DBI.pm 2007-07-19 14:05:59 UTC (rev 260)
@@ -87,6 +87,11 @@
return $value;
}
+sub _dump {
+ my ($self, $sql, %args) = @_;
+ my $dbh = CPAN::Forum::DBI::db_Main();
+ return $dbh->selectall_arrayref($sql, \%args);
+}
1;
Modified: trunk/templates/faq.tmpl
===================================================================
--- trunk/templates/faq.tmpl 2007-07-19 14:05:42 UTC (rev 259)
+++ trunk/templates/faq.tmpl 2007-07-19 14:05:59 UTC (rev 260)
@@ -154,8 +154,9 @@
<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>
+ <br />
+ <a href="/db_dump.tar.bz2">Partial dump of the database</a>For now mainly the tables related to tags
</dd>
-
</dl>
</div>
<TMPL_INCLUDE NAME="footer.tmpl">
More information about the Cpan-forum-commit
mailing list