Permalink
Browse files

reworked osname functionality

  • Loading branch information...
1 parent e35c7a2 commit 07677d574a5e533ed24d455a6ec1de32b952fc7c @barbie committed Oct 19, 2009
Showing with 42 additions and 16 deletions.
  1. +3 −0 CHANGES
  2. +0 −1 MANIFEST
  3. +2 −2 META.yml
  4. +1 −1 bin/cpanstats-reparse
  5. +22 −3 lib/CPAN/Testers/Data/Generator.pm
  6. +0 −8 t/10functions.t
  7. +14 −1 t/12generate.t
View
@@ -1,5 +1,8 @@
Revision history for Perl module CPAN::Testers::Data::Generator.
+0.38 19/10/2009
+ - added functionality to update the osname table.
+
0.37 07/06/2009
- added page request functionality.
- added release summary functionality.
View
@@ -18,7 +18,6 @@ examples/generate.sh
examples/settings-example.ini
lib/CPAN/Testers/Data/Generator.pm
t/01base.t
-t/10functions.t
t/12generate.t
t/90podtest.t
t/91podcover.t
View
@@ -1,6 +1,6 @@
--- #YAML:1.0
name: CPAN-Testers-Data-Generator
-version: 0.37
+version: 0.38
abstract: Download and summarize CPAN Testers data
author:
- Barbie <barbie@cpan.org>
@@ -36,7 +36,7 @@ build_requires:
provides:
CPAN::Testers::Data::Generator:
file: lib/CPAN/Testers/Data/Generator.pm
- version: 0.37
+ version: 0.38
no_index:
directory:
@@ -31,7 +31,7 @@ local articles.db database is used to reparse, no NNTP lookup is used.
The ability to ignore field checking for specific fields is enabled via the
use of the exclude option. Using a comma separated list you may enter one
or more of the fields 'dist', 'version', 'from', 'perl' and 'platform'.
-This is useful for parsing a faulty report and then using upstats.pl to
+This is useful for parsing a faulty report and then using cpanstats-update to
amend the appropriate field to the correct value.
=cut
@@ -4,7 +4,7 @@ use warnings;
use strict;
use vars qw($VERSION);
-$VERSION = '0.37';
+$VERSION = '0.38';
#----------------------------------------------------------------------------
# Library Modules
@@ -44,6 +44,13 @@ sub new {
$self->{$key} = $hash{$key} || $cfg->val('MAIN',$key);
}
+ my @rows = $self->{CPANSTATS}->get_query('array',q{SELECT osname,ostitle FROM osname});
+ for my $row (@rows) {
+ $self->{OSNAMES}{lc $row->[0]} = $row->[1];
+ }
+
+ ($self->{nntp_num}, $self->{nntp_first}, $self->{nntp_last}) = (0,0,0);
+
return $self;
}
@@ -131,7 +138,7 @@ sub reparse {
for my $id (@ids) {
#print STDERR "id=[$id], last=[$last]\n";
- next if($id < 1 || $id > $last);
+ next if($id < 1 || ($id > $last && $id > $self->{nntp_last}));
my $article;
my @rows = $self->{LITEARTS}->get_query('array','SELECT * FROM articles WHERE id = ?',$id);
@@ -189,6 +196,8 @@ sub nntp_connect {
my $nntp = Net::NNTP->new("nntp.perl.org") or die "Cannot connect to NNTP server [nntp.perl.org]\n";
($self->{nntp_num}, $self->{nntp_first}, $self->{nntp_last}) = $nntp->group("perl.cpan.testers");
+ #print STDERR "NNTP: (num,first,last) = ($self->{nntp_num}, $self->{nntp_first}, $self->{nntp_last})\n";
+
return $nntp;
}
@@ -232,7 +241,7 @@ sub parse_article {
$from = $object->from;
$perl = $object->perl;
$platform = $object->archname;
- $osname = $object->osname;
+ $osname = $self->_osname($object->osname);
$osvers = $object->osvers;
$from =~ s/'/''/g; #'
@@ -352,6 +361,16 @@ sub _oncpan {
return 1; # on cpan or new upload
}
+sub _osname {
+ my ($self,$name) = @_;
+ my $lname = lc $name;
+ unless($self->{OSNAME}{$lname}) {
+ $self->{OSNAMES}{$lname} = uc($name);
+ $self->{CPANSTATS}->do_query(qq{INSERT INTO osname (osname,ostitle) VALUES ('$name','$self->{OSNAMES}{$lname}'});
+ }
+ return $name;
+}
+
sub _log {
my $self = shift;
my $log = $self->{logfile} or return;
View
@@ -1,8 +0,0 @@
-#!/usr/bin/perl -w
-use strict;
-use Test::More tests => 1;
-use CPAN::Testers::Data::Generator;
-
-my $t = CPAN::Testers::Data::Generator->new(config => './t/test-config.ini');
-isa_ok($t,'CPAN::Testers::Data::Generator');
-
View
@@ -26,7 +26,7 @@ if($@) {
if(create_db(0)) {
plan skip_all => 'Cannot create temporary databases';
} else {
- plan tests => 49;
+ plan tests => 50;
}
# continue with testing
@@ -81,6 +81,8 @@ SKIP: {
logfile => $directory . '/cpanstats.log'
);
+ isa_ok($t,'CPAN::Testers::Data::Generator');
+
# nothing should be created yet
ok(!-f $directory . '/cpanstats.log');
@@ -276,6 +278,9 @@ sub config_db {
# distribution. As soon as Test::Database does become stable
# further work to complete testing will be done.
+ # last Test-Database install attempt was version 1.07, which still doesn't
+ # pass its own tests on my linux distros :(
+
return;
my $db = shift;
@@ -389,6 +394,14 @@ sub create_db {
released int(16) NOT NULL,
author varchar(32) NOT NULL,
PRIMARY KEY (dist)
+ )',
+
+ 'DROP TABLE IF EXISTS osname',
+ 'CREATE TABLE osname (
+ id int(10) unsigned NOT NULL auto_increment,
+ osname varchar(255) NOT NULL,
+ ostitle varchar(255) NOT NULL,
+ PRIMARY KEY (id)
)'
;
dosql('CPANSTATS',\@sql) or return 1;

0 comments on commit 07677d5

Please sign in to comment.