|
38 | 38 |
|
39 | 39 | # look up this module in ElasticSearch and see what we have on it |
40 | 40 | my $results = $es_file->search( |
41 | | - size => 100, # shouldn't get more than this |
42 | | - fields => [ |
43 | | - qw< name release author distribution version authorized indexed maturity date > |
44 | | - ], |
45 | | - query => { |
| 41 | + query => { |
46 | 42 | bool => { |
47 | 43 | must => [ |
48 | 44 | { term => { 'module.name' => $pkg } }, |
|
51 | 47 | ], |
52 | 48 | }, |
53 | 49 | }, |
| 50 | + size => 100, # shouldn't get more than this |
| 51 | + _source => [ qw< |
| 52 | + name |
| 53 | + release |
| 54 | + author |
| 55 | + distribution |
| 56 | + version |
| 57 | + authorized |
| 58 | + indexed |
| 59 | + maturity |
| 60 | + date |
| 61 | + > ], |
| 62 | + |
54 | 63 | ); |
55 | 64 | my @files = @{ $results->{hits}{hits} }; |
56 | 65 |
|
57 | 66 | # now find the first latest releases for these files |
58 | 67 | foreach my $file (@files) { |
59 | 68 | my $release_results = $es_release->search( |
60 | | - size => 1, |
61 | | - fields => [qw< name status authorized version id date >], |
62 | | - query => { |
| 69 | + query => { |
63 | 70 | bool => { |
64 | 71 | must => [ |
65 | | - { term => { name => $file->{fields}{release} } }, |
| 72 | + { |
| 73 | + term => |
| 74 | + { name => $file->{_source}{release} } |
| 75 | + }, |
66 | 76 | { term => { status => 'latest' } }, |
67 | 77 | ], |
68 | 78 | }, |
69 | 79 | }, |
| 80 | + size => 1, |
| 81 | + _source => [qw< name status authorized version id date >], |
70 | 82 | ); |
71 | 83 |
|
72 | 84 | push @releases, $release_results->{hits}{hits}[0] |
|
78 | 90 | if ( !@releases ) { |
79 | 91 | foreach my $file (@files) { |
80 | 92 | my $release_results = $es_release->search( |
81 | | - size => 1, |
82 | | - fields => |
83 | | - [qw< name status authorized version id date >], |
84 | | - query => { |
| 93 | + query => { |
85 | 94 | bool => { |
86 | 95 | must => [ |
87 | | - { term => { name => $file->{fields}{release} } }, |
| 96 | + { |
| 97 | + term => { |
| 98 | + name => $file->{_source}{release} |
| 99 | + } |
| 100 | + }, |
88 | 101 | ], |
89 | 102 | }, |
90 | 103 | }, |
| 104 | + size => 1, |
| 105 | + _source => |
| 106 | + [qw< name status authorized version id date >], |
91 | 107 | ); |
92 | 108 |
|
93 | 109 | push @releases, @{ $release_results->{hits}{hits} }; |
|
97 | 113 | # if we found the releases tell them about it |
98 | 114 | if (@releases) { |
99 | 115 | if ( @releases == 1 |
100 | | - and $releases[0]->{fields}{status} eq 'latest' ) |
| 116 | + and $releases[0]->{_source}{status} eq 'latest' ) |
101 | 117 | { |
102 | 118 | log_info { |
103 | | - "Found latest release $releases[0]->{fields}{name} for $pkg" |
| 119 | + "Found latest release $releases[0]->{_source}{name} for $pkg" |
104 | 120 | } |
105 | 121 | unless $errors_only; |
106 | 122 | } |
107 | 123 | else { |
108 | 124 | log_error {"Could not find latest release for $pkg"}; |
109 | 125 | foreach my $rel (@releases) { |
110 | | - log_warn {" Found release $rel->{fields}{name}"}; |
111 | | - log_warn {" STATUS : $rel->{fields}{status}"}; |
| 126 | + log_warn {" Found release $rel->{_source}{name}"}; |
| 127 | + log_warn {" STATUS : $rel->{_source}{status}"}; |
112 | 128 | log_warn { |
113 | | - " AUTORIZED : $rel->{fields}{authorized}" |
| 129 | + " AUTORIZED : $rel->{_source}{authorized}" |
114 | 130 | }; |
115 | | - log_warn {" DATE : $rel->{fields}{date}"}; |
| 131 | + log_warn {" DATE : $rel->{_source}{date}"}; |
116 | 132 | } |
117 | 133 |
|
118 | 134 | $error_count++; |
|
123 | 139 | "Module $pkg doesn't have any releases in ElasticSearch!" |
124 | 140 | }; |
125 | 141 | foreach my $file (@files) { |
126 | | - log_warn {" Found file $file->{fields}{name}"}; |
127 | | - log_warn {" RELEASE : $file->{fields}{release}"}; |
128 | | - log_warn {" AUTHOR : $file->{fields}{author}"}; |
| 142 | + log_warn {" Found file $file->{_source}{name}"}; |
| 143 | + log_warn {" RELEASE : $file->{_source}{release}"}; |
| 144 | + log_warn {" AUTHOR : $file->{_source}{author}"}; |
129 | 145 | log_warn { |
130 | | - " AUTHORIZED : $file->{fields}{authorized}" |
| 146 | + " AUTHORIZED : $file->{_source}{authorized}" |
131 | 147 | }; |
132 | | - log_warn {" DATE : $file->{fields}{date}"}; |
| 148 | + log_warn {" DATE : $file->{_source}{date}"}; |
133 | 149 | } |
134 | 150 | $error_count++; |
135 | 151 | } |
|
0 commit comments