Skip to content

Commit ed95ff7

Browse files
committed
Fixed contributor indexing + test
1 parent f0fb759 commit ed95ff7

File tree

4 files changed

+31
-13
lines changed

4 files changed

+31
-13
lines changed

bin/contributor.pl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929

3030
run();
3131

32+
$es_contributor->index_refresh;
33+
3234
log_info {"done"};
3335

3436
###
@@ -185,7 +187,7 @@ ($release)
185187
$authors = [ grep { $_ ne 'unknown' } @$authors ];
186188

187189
my $author_email = $author_mapping->{$author_name}
188-
//= eval { $es_author->get_source( id => $author_name )->{email}; }
190+
//= eval { $es_author->get_source( $author_name )->{email}; }
189191
or return [];
190192
191193
my $author_info = {

lib/MetaCPAN/ES.pm

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,11 @@ sub get_ids ( $self, %args ) {
141141
}
142142

143143
sub get_source ( $self, $id ) {
144-
return $self->{es}->get_source($id);
144+
return $self->{es}->get_source(
145+
index => $self->{index},
146+
type => $self->{type},
147+
id => $id,
148+
);
145149
}
146150

147151
sub delete_ids ( $self, $ids ) {

lib/MetaCPAN/File.pm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,6 @@ sub set_suggest ($self) {
289289

290290
$self->{suggest} = +{
291291
input => [$doc],
292-
payload => { doc_name => $doc },
293292
weight => $weight,
294293
};
295294
}

t/00_setup.t

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,23 +116,22 @@ subtest 'Release Indexing' => sub {
116116
# run the release indexing script for a tarball
117117
`perl $release_script $release_file`;
118118

119-
my $es_file = MetaCPAN::ES->new( index => 'file' );
120-
my $file_search_total = $es_file->search(
119+
my $es_file = MetaCPAN::ES->new( index => 'file' );
120+
my $file_count = $es_file->count(
121121
body => {
122122
query => { match => { release => 'HTML-Parser-3.83' } },
123123
}
124-
)->{hits}{total};
125-
ok( $file_search_total > 0, "Found files for HTML-Parser-3.83" );
124+
)->{count};
125+
ok( $file_count > 0, "Found ($file_count) files for HTML-Parser-3.83" );
126126

127-
my $es_release = MetaCPAN::ES->new( index => 'release' );
128-
my $release_search_total = $es_release->search(
127+
my $es_release = MetaCPAN::ES->new( index => 'release' );
128+
my $release_count = $es_release->count(
129129
body => {
130130
query => { match => { name => 'HTML-Parser-3.83' } },
131131
}
132-
)->{hits}{total};
132+
)->{count};
133133

134-
ok( $release_search_total == 1,
135-
"Found release entries for HTML-Parser-3.83" );
134+
ok( $release_count == 1, "Found ($release_count) release entries for HTML-Parser-3.83" );
136135
};
137136

138137
subtest 'Cover Indexing' => sub {
@@ -147,8 +146,22 @@ subtest 'Cover Indexing' => sub {
147146
"Found cover data for HTML-Parser-3.83" );
148147
};
149148

149+
subtest 'Contributor Indexing' => sub {
150+
my $contributor_script = $d_bin->child('contributor.pl');
151+
152+
# run the contributor indexing script
153+
`perl $contributor_script -release OALDERS/HTML-Parser-3.83`;
154+
155+
my $es_contributor = MetaCPAN::ES->new( index => 'contributor' );
156+
my $contributor_count = $es_contributor->count(
157+
body => {
158+
query => { match => { release_name => 'HTML-Parser-3.83' } },
159+
}
160+
)->{count};
161+
ok( $contributor_count > 0, "Found ($contributor_count) contributors for HTML-Parser-3.83" );
162+
};
163+
150164
# TODO:
151-
# contributor
152165
# cve
153166
# favorite
154167

0 commit comments

Comments
 (0)