Navigation Menu

Skip to content

Commit

Permalink
Adds 1a-last-100-favorited-dists-by-user-es.pl
Browse files Browse the repository at this point in the history
  • Loading branch information
oalders committed Jul 27, 2013
1 parent 0e4239d commit 076a169
Showing 1 changed file with 28 additions and 0 deletions.
@@ -0,0 +1,28 @@
#!/usr/bin/env perl

use strict;
use warnings;

use Data::Printer;
use MetaCPAN::Util qw( es );

my $id = shift @ARGV;

die "usage: ./bin/carton $0 \$user_id" if !$id;

my $faves = es()->search(
index => 'v0',
type => 'favorite',
query => {
filtered => {
query => { match_all => {} },
filter => { term => { 'favorite.user' => $id } }
},
},
sort => [ { date => 'desc' } ],
size => 100,
);

my @dists = map { $_->{_source} } @{ $faves->{hits}->{hits} };

p @dists;

0 comments on commit 076a169

Please sign in to comment.