Skip to content

mickey/river #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions bin/river.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
use strict;
use warnings;
use v5.36;

use Cpanel::JSON::XS qw< decode_json >;
use Getopt::Long;

use MetaCPAN::Logger qw< :log :dlog >;

use MetaCPAN::ES;
use MetaCPAN::Ingest qw< read_url >;

# setup
my $river_url //= 'https://neilb.org/river-of-cpan.json.gz';
my $river_data = decode_json( read_url($river_url) );

my $es = MetaCPAN::ES->new( index => "cpan", type => "distribution" );
my $bulk = $es->bulk();

log_info {'Updating the distribution index'};

for my $data ( @{$river_data} ) {
my $dist = delete $data->{dist};

$bulk->update( {
id => $dist,
doc => {
name => $dist,
river => $data,
},
doc_as_upsert => 1,
} );
}

$bulk->flush;

1;

__END__

=pod

=head1 SYNOPSIS

# bin/metacpan river

=head1 DESCRIPTION

Retrieves the CPAN river data from its source and
updates our ES information.

This can then be accessed here:

http://fastapi.metacpan.org/v1/distribution/Moose
http://fastapi.metacpan.org/v1/distribution/HTTP-BrowserDetect

=cut
Loading