From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1RjCny-0004Jj-Lx for garchives@archives.gentoo.org; Fri, 06 Jan 2012 16:38:11 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 4BE4B21C036; Fri, 6 Jan 2012 16:38:03 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 0C6B321C036 for ; Fri, 6 Jan 2012 16:38:02 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 5A55C1B4055 for ; Fri, 6 Jan 2012 16:38:02 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 6B9C680042 for ; Fri, 6 Jan 2012 16:38:01 +0000 (UTC) From: "Kent Fredric" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Kent Fredric" Message-ID: <35b9a8c3d05650d4023e7b61ded134314f1f498d.kent@gentoo> Subject: [gentoo-commits] proj/perl-overlay:master commit in: scripts/, scripts/lib/ X-VCS-Repository: proj/perl-overlay X-VCS-Files: scripts/lib/metacpan.pm scripts/package_log.pl X-VCS-Directories: scripts/ scripts/lib/ X-VCS-Committer: kent X-VCS-Committer-Name: Kent Fredric X-VCS-Revision: 35b9a8c3d05650d4023e7b61ded134314f1f498d Date: Fri, 6 Jan 2012 16:38:01 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: c8da3647-e7b2-4741-b57b-3e018a6dc500 X-Archives-Hash: e4c0babc9a5854c6278722b74ff41975 commit: 35b9a8c3d05650d4023e7b61ded134314f1f498d Author: Kent Fredric gmail com> AuthorDate: Fri Jan 6 06:03:38 2012 +0000 Commit: Kent Fredric gmail com> CommitDate: Fri Jan 6 06:03:38 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/perl-overlay.= git;a=3Dcommit;h=3D35b9a8c3 [scripts] optimise package query, fix end-point to _search, add debug opt= ions in the WWW layer --- scripts/lib/metacpan.pm | 19 ++++++++++++++--- scripts/package_log.pl | 48 +++++++++++++++++++++++++++++------------= ----- 2 files changed, 45 insertions(+), 22 deletions(-) diff --git a/scripts/lib/metacpan.pm b/scripts/lib/metacpan.pm index 58ce0f2..702a2a9 100644 --- a/scripts/lib/metacpan.pm +++ b/scripts/lib/metacpan.pm @@ -20,11 +20,22 @@ sub mcpan { root_dir =3D> File::Spec->catdir( File::Spec->tmpdir, 'gentoo-meta= cpan-cache' ), ); require WWW::Mechanize::Cached; - my $mech =3D WWW::Mechanize::Cached->new( - cache =3D> $cache, - timeout =3D> 20000, + my $mech; + + if ( defined $ENV{WWW_MECH_NOCACHE} ) { + $mech =3D LWP::UserAgent->new(); + } else { + $mech =3D WWW::Mechanize::Cached->new( + cache =3D> $cache, + timeout =3D> 20000, autocheck =3D> 1, - ); + ); + } + if ( defined $ENV{WWW_MECH_DEBUG} ) { + $mech->add_handler("request_send", sub { warn shift->dump ; retu= rn }); + $mech->add_handler("response_done", sub { warn shift->dump ; ret= urn }); + + } require HTTP::Tiny::Mech; my $tinymech =3D HTTP::Tiny::Mech->new( mechua =3D> $mech ); require MetaCPAN::API; diff --git a/scripts/package_log.pl b/scripts/package_log.pl index 70547b3..a6bc9fb 100755 --- a/scripts/package_log.pl +++ b/scripts/package_log.pl @@ -49,34 +49,45 @@ my $singleflags; =20 if ( $flags->{help} or $singleflags->{h} ) { print help(); exit 0; } =20 -my $oldest_date =3D '2011-09-01T00:00:00.000Z'; -my $newest_date =3D '2012-01-01T00:00:00.000Z'; +my $oldest_date =3D '2011-10-01T00:00:00.000Z'; +my $newest_date =3D '2012-02-01T00:00:00.000Z'; =20 my $search =3D {}; =20 -$search->{query} =3D { - terms =3D> { - distribution =3D> [ @ARGV, ], - minimum_match =3D> 1, - }, -}; +my $and =3D []; =20 if ( not $flags->{all} ) { - $search->{filter} =3D { - range =3D> { - date =3D> { - from =3D> $oldest_date, - to =3D> $newest_date, - }, - }, - }; + push @{$and}, { + range =3D> { + date =3D> { + from =3D> $oldest_date, + to =3D> $newest_date, + } + } + }; } + +push @{$and} , { + term =3D> { + 'distribution' =3D> @ARGV, +# minimum_match =3D> 1, + } +}; + +$search->{query} =3D { + constant_score =3D> { + filter =3D> { + and =3D> $and, + } + } +}; + $search->{sort} =3D [ =20 # { 'author' =3D> 'asc', }, { 'date' =3D> 'desc', }, ]; -$search->{size} =3D 1024; +$search->{size} =3D 10; =20 $search->{fields} =3D [qw( author name date distribution version )]; =20 @@ -84,9 +95,10 @@ if ( $flags->{deps} ) { push @{ $search->{fields} }, '_source.dependency'; } =20 + _log( ['initialized: fetching search results'] ); =20 -my $results =3D mcpan->post( 'release', $search ); +my $results =3D mcpan->post( 'release/_search', $search ); =20 _log( [ 'fetched %s results', scalar @{ $results->{hits}->{hits} } ] ); =20