File tree Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Original file line number Diff line number Diff line change 1+ use strict;
2+ use warnings;
3+ use v5.36;
4+
5+ use Cpanel::JSON::XS qw< decode_json > ;
6+ use Getopt::Long;
7+
8+ use MetaCPAN::Logger qw< :log :dlog > ;
9+
10+ use MetaCPAN::ES;
11+ use MetaCPAN::Ingest qw< read_url > ;
12+
13+ # setup
14+ my $river_url //= ' https://neilb.org/river-of-cpan.json.gz' ;
15+ my $river_data = decode_json( read_url($river_url ) );
16+
17+ my $es = MetaCPAN::ES-> new( index => " cpan" , type => " distribution" );
18+ my $bulk = $es -> bulk();
19+
20+ log_info {' Updating the distribution index' };
21+
22+ for my $data ( @{$river_data } ) {
23+ my $dist = delete $data -> {dist };
24+
25+ $bulk -> update( {
26+ id => $dist ,
27+ doc => {
28+ name => $dist ,
29+ river => $data ,
30+ },
31+ doc_as_upsert => 1,
32+ } );
33+ }
34+
35+ $bulk -> flush;
36+
37+ 1;
38+
39+ __END__
40+
41+ =pod
42+
43+ =head1 SYNOPSIS
44+
45+ # bin/metacpan river
46+
47+ =head1 DESCRIPTION
48+
49+ Retrieves the CPAN river data from its source and
50+ updates our ES information.
51+
52+ This can then be accessed here:
53+
54+ http://fastapi.metacpan.org/v1/distribution/Moose
55+ http://fastapi.metacpan.org/v1/distribution/HTTP-BrowserDetect
56+
57+ =cut
You can’t perform that action at this time.
0 commit comments