CPAN-Testers-Schema
view release on metacpan or search on metacpan
lib/CPAN/Testers/Schema.pm view on Meta::CPAN
#pod if ( $row->state eq 'fail' ) {
#pod say sprintf "Fail report from %s: http://cpantesters.org/cpan/report/%s",
#pod $row->tester, $row->guid;
#pod }
#pod }
#pod
#pod =head1 DESCRIPTION
#pod
#pod This is a L<DBIx::Class> Schema for the CPANTesters statistics database.
#pod This database is generated by processing the incoming data from L<the
#pod CPANTesters Metabase|http://metabase.cpantesters.org>, and extracting
#pod the useful fields like distribution, version, platform, and others (see
#pod L<CPAN::Testers::Schema::Result::Stats> for a full list).
#pod
#pod This is its own distribution so that it can be shared by the backend
#pod processing, data APIs, and the frontend web application.
#pod
#pod =head1 SEE ALSO
#pod
#pod L<CPAN::Testers::Schema::Result::Stats>, L<DBIx::Class>
#pod
#pod =cut
use CPAN::Testers::Schema::Base;
use File::Share qw( dist_dir );
use Path::Tiny qw( path );
use List::Util qw( uniq );
use base 'DBIx::Class::Schema';
use Mojo::UserAgent;
use DateTime::Format::ISO8601;
__PACKAGE__->load_namespaces;
__PACKAGE__->load_components(qw/Schema::Versioned/);
__PACKAGE__->upgrade_directory( dist_dir( 'CPAN-Testers-Schema' ) );
#pod =method connect_from_config
#pod
#pod my $schema = CPAN::Testers::Schema->connect_from_config( %extra_conf );
#pod
#pod Connect to the MySQL database using a local MySQL configuration file
#pod in C<$HOME/.cpanstats.cnf>. This configuration file should look like:
#pod
#pod [client]
#pod host = ""
#pod database = cpanstats
#pod user = my_usr
#pod password = my_pwd
#pod
#pod See L<DBD::mysql/mysql_read_default_file>.
#pod
#pod C<%extra_conf> will be added to the L<DBIx::Class::Schema/connect>
#pod method in the C<%dbi_attributes> hashref (see
#pod L<DBIx::Class::Storage::DBI/connect_info>).
#pod
#pod =cut
# Convenience connect method
sub connect_from_config ( $class, %config ) {
my $schema = $class->connect(
"DBI:mysql:mysql_read_default_file=$ENV{HOME}/.cpanstats.cnf;".
"mysql_read_default_group=application;mysql_enable_utf8=1",
undef, # user
undef, # pass
{
AutoCommit => 1,
RaiseError => 1,
mysql_enable_utf8 => 1,
quote_char => '`',
name_sep => '.',
%config,
},
);
return $schema;
}
#pod =method ordered_schema_versions
#pod
#pod Get the available schema versions by reading the files in the share
#pod directory. These versions can then be upgraded to using the
#pod L<cpantesters-schema> script.
#pod
#pod =cut
sub ordered_schema_versions( $self ) {
my @versions =
uniq sort
map { /[\d.]+-([\d.]+)/ }
grep { /CPAN-Testers-Schema-[\d.]+-[\d.]+-MySQL[.]sql/ }
path( dist_dir( 'CPAN-Testers-Schema' ) )->children;
return '0.000', @versions;
}
#pod =method populate_from_api
#pod
#pod $schema->populate_from_api( \%search, @tables );
#pod
#pod Populate the given tables from the CPAN Testers API (L<http://api.cpantesters.org>).
#pod C<%search> has the following keys:
#pod
#pod =over
#pod
#pod =item dist
#pod
#pod A distribution to populate
#pod
#pod =item version
#pod
#pod A distribution version to populate
#pod
#pod =item author
#pod
#pod Populate an author's data
#pod
#pod =back
#pod
#pod The available C<@tables> are:
#pod
#pod =over
#pod
#pod =item * upload
#pod
#pod =item * release
#pod
#pod =item * summary
#pod
#pod =item * report
#pod
( run in 1.456 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )