[Cpan-forum-commit] rev 171 - in trunk: . bin lib/CPAN schema
svn at pti.co.il
svn at pti.co.il
Fri Aug 25 18:15:43 IDT 2006
Author: gabor
Date: 2006-08-25 18:15:43 +0300 (Fri, 25 Aug 2006)
New Revision: 171
Modified:
trunk/
trunk/bin/populate.pl
trunk/lib/CPAN/Forum.pm
trunk/schema/schema.sql
Log:
populate authors table
fix rss of dist/DIST-NAME
Property changes on: trunk
___________________________________________________________________
Name: svk:merge
- 8c4c90e1-83eb-0310-96eb-e7cb62807872:/local/cpan-forum:10998
+ 8c4c90e1-83eb-0310-96eb-e7cb62807872:/local/cpan-forum:10999
Modified: trunk/bin/populate.pl
===================================================================
--- trunk/bin/populate.pl 2006-08-25 15:15:39 UTC (rev 170)
+++ trunk/bin/populate.pl 2006-08-25 15:15:43 UTC (rev 171)
@@ -20,9 +20,23 @@
dir => "$Bin/../db",
);
-GetOptions(\%opts, "sendmail", "source=s", "dir=s") or die;
+GetOptions(\%opts, "sendmail", "source=s", "dir=s", "fetch", "help")
+ or usage();
+usage() if $opts{help};
+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");
@@ -36,13 +50,15 @@
if (not $opts{source}) {
my $file = "02packages.details.txt";
$opts{source} = "$opts{dir}/$file";
+}
+if ($opts{fetch}) {
unlink $opts{source} if -e $opts{source};
# must have downloaded and un-gzip-ed
# ~/mirror/cpan/modules/02packages.details.txt.gz
- print "Fecthing $file from CPAN\n";
+ print "Fecthing $opts{source} from CPAN\n";
getstore("http://www.cpan.org/modules/02packages.details.txt.gz", "$opts{source}.gz");
- print "Unzipping $file\n";
+ print "Unzipping $opts{source}\n";
system("gunzip $opts{source}.gz");
}
@@ -57,19 +73,20 @@
new => "",
);
+LINE:
foreach my $d (@distributions) {
# skip scripts
- next if not $d->prefix or $d->prefix =~ m{^\w/\w\w/\w+/scripts/};
+ next LINE if not $d->prefix or $d->prefix =~ m{^\w/\w\w/\w+/scripts/};
my $name = $d->dist;
if (not $name) {
#warn "No name: " . $d->prefix . "\n";
- next;
+ next LINE;
}
# for now skip names that start with lower case
- #next if $name =~ /^[a-z]/;
+ #next LINE if $name =~ /^[a-z]/;
my %new = (
version => ($d->version() || ""),
@@ -95,16 +112,26 @@
}
$g->update if $changed;
- next;
+ next LINE;
}
$message{new} .= sprintf "%s %s\n", $name, $new{version}, $new{pauseid};
+ my $pause;
eval {
+ $pause = CPAN::Forum::Authors->find_or_create({ pauseid => $new{pauseid} });
+ };
+ if ($@) {
+ warn "$name\n";
+ warn $@;
+ next LINE;
+ }
+
+ eval {
my $g = CPAN::Forum::Groups->create({
name => $name,
gtype => $CPAN::Forum::DBI::group_types{Distribution},
version => $new{version},
- pauseid => $new{pauseid},
+ pauseid => $pause->id,
});
};
if ($@) {
@@ -113,6 +140,7 @@
}
}
+
#open my $out, ">", $version_file or die "Could not open '$version_file' for writing $!\n";
#foreach my $name (sort keys %version) {
# print $out qq("$name","$version{$name}"\n);
Modified: trunk/lib/CPAN/Forum.pm
===================================================================
--- trunk/lib/CPAN/Forum.pm 2006-08-25 15:15:39 UTC (rev 170)
+++ trunk/lib/CPAN/Forum.pm 2006-08-25 15:15:43 UTC (rev 171)
@@ -248,6 +248,21 @@
=head2 TODO
+In order to prepare a downloadable version of the database we need to hide the
+personal infromation:
+ update users set email = 'test_' || id || '@cpanforum.com' where id in(select id from users);
+ update users set password = 'testpw';
+
+ -- maybe even change the usernames? but I think the ids are already public
+ -- so it won't bring any additional privacy or security
+
+ delete from sessions;
+
+ delete from configure; -- ???
+ delete user_in_group; -- ???
+
+
+
Removed the use of CPAN::Forum::Build - need to see what was it doing and
replace its functionality with something better
@@ -2163,8 +2178,9 @@
=head2 rss
Provide RSS feed
-/rss latest 20 entries
-/rss/dist/Distro-Name latest 20 entries of that distro name
+/rss/all latest N entries
+/rss/dist/Distro-Name latest N entries of that distro name
+/rss/author/PAUSEID
=cut
@@ -2176,7 +2192,9 @@
my $it;
if (@params > 1 and $params[0] eq "dist") {
my $dist = $params[1];
- $it = CPAN::Forum::Posts->search(gid => $dist, {order_by => 'date DESC'}),
+ $self->log->debug("rss of dist: '$dist'");
+ my ($group) = CPAN::Forum::Groups->search({ name => $dist });
+ $it = CPAN::Forum::Posts->search(gid => $group->id, {order_by => 'date DESC'}),
} else {
$it = CPAN::Forum::Posts->retrieve_latest($cnt);
}
Modified: trunk/schema/schema.sql
===================================================================
--- trunk/schema/schema.sql 2006-08-25 15:15:39 UTC (rev 170)
+++ trunk/schema/schema.sql 2006-08-25 15:15:43 UTC (rev 171)
@@ -98,7 +98,7 @@
CREATE TABLE authors (
id INTEGER PRIMARY KEY auto_increment,
- pauseid VARCHAR(100)
+ pauseid VARCHAR(100) UNIQUE NOT NULL
);
More information about the Cpan-forum-commit
mailing list