[Bps-public-commit] cpan2rt branch, master, updated. aed7138b92cbba5a299a5cc94bd355a846375796

Dianne Skoll dianne at bestpractical.com
Thu Feb 25 17:03:36 EST 2021


The branch, master has been updated
       via  aed7138b92cbba5a299a5cc94bd355a846375796 (commit)
      from  cdb51099d249207e1d6312ad6b564163efe9447e (commit)

Summary of changes:
 lib/CPAN2RT.pm | 70 ++++++++++++++++------------------------------------------
 1 file changed, 19 insertions(+), 51 deletions(-)

- Log -----------------------------------------------------------------
commit aed7138b92cbba5a299a5cc94bd355a846375796
Author: Dianne Skoll <dianne at bestpractical.com>
Date:   Thu Feb 25 17:02:51 2021 -0500

    Use MetaCPAN::Client instead of ElasticSearch to sync bugtracker info

diff --git a/lib/CPAN2RT.pm b/lib/CPAN2RT.pm
index 3cdd4c1..bfadefd 100644
--- a/lib/CPAN2RT.pm
+++ b/lib/CPAN2RT.pm
@@ -310,54 +310,10 @@ This updates and adds to existing queues.
 sub _sync_bugtracker_cpan2rt {
     my $self = shift;
 
-    require ElasticSearch;
-    my $es = ElasticSearch->new(
-        servers     => 'fastapi.metacpan.org',
-        no_refresh  => 1,
-        transport   => 'http',
-    );
-    $es->transport->client->agent(join "/", __PACKAGE__, $VERSION);
-
-    # Ian Norton wrote:
-    # > Thomas Sibley wrote:
-    # >> 2) Is it feasible to further limit returned [MetaCPAN] results to those where
-    # >> .web or .mailto lacks "rt.cpan.org"?
-    # > 
-    # > Spoke to the metacpan guys on irc and seemingly it would be expensive to
-    # > do this server side.  Request submitted to have the fields added as full
-    # > text searchable - https://github.com/CPAN-API/cpan-api/issues/238
-    # > following a chat with clintongormley.  Once that's done then we can
-    # > improve this.
-
-    # Pull the details of distribution bugtrackers
-    my $scroller = $es->scrolled_search(
-        query       => { match_all => {} },
-        size        => 100,
-        search_type => 'scan',
-        scroll      => '5m',
-        index       => 'v1',
-        type        => 'release',
-        fields  => [ "distribution" , "resources.bugtracker" ],
-        filter  => {
-            and => [{
-                or => [
-                    {
-                        and => [
-                            { exists => { field => "resources.bugtracker.mailto" }},
-                            { not    => { query => { wildcard => { "resources.bugtracker.mailto" => '*rt.cpan.org*' }}}},
-                        ],
-                    },{
-                        and => [
-                            { exists => { field => "resources.bugtracker.web" }},
-                            { not    => { query => { wildcard => { "resources.bugtracker.web" => '*://rt.cpan.org*' }}}},
-                        ],
-                    }
-                ]},
-                { term => { "release.status"   => "latest" }},
-                { term => { "release.maturity" => "released" }},
-            ],
-        },
-    );
+    require MetaCPAN::Client;
+    my $mc = MetaCPAN::Client->new;
+
+    my $scroller = $mc->all('releases');
 
     unless ( defined($scroller) ) {
         die("Request to api.metacpan.org failed.\n");
@@ -369,18 +325,30 @@ sub _sync_bugtracker_cpan2rt {
 
     # Iterate the results from MetaCPAN
     while ( my $result = $scroller->next ) {
+        my $data = $result->{data};
+
         my $bugtracker = {};
 
         # Record data
-        my $dist   = $result->{"fields"}->{"distribution"};
-        my $mailto = $result->{"fields"}->{"resources.bugtracker"}->{"mailto"};
-        my $web    = $result->{"fields"}->{"resources.bugtracker"}->{"web"};
+        my $dist   = $data->{distribution};
+        my $mailto;
+        my $web;
+        if ($data->{resources} && $data->{resources}->{bugtracker}) {
+            $mailto = $data->{resources}->{bugtracker}->{mailto};
+            $web = $data->{resources}->{bugtracker}->{web};
+        }
 
         if (!$dist) {
             #debug { "Result without distribution: " . Data::Dumper::Dumper($result) };
             next;
         }
 
+        next unless $data->{maturity};
+        next unless $data->{maturity} eq 'released';
+        next unless $data->{status};
+        next unless $data->{status} eq 'latest';
+
+
         debug { "Got '$dist' ($mailto, $web)" };
 
         # Email based alternative - we don't care if this is rt.cpan.org

-----------------------------------------------------------------------


More information about the Bps-public-commit mailing list