-
Notifications
You must be signed in to change notification settings - Fork 194
/
Copy pathDistribution.pm
66 lines (52 loc) · 1.19 KB
/
Distribution.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package MetaCPAN::Document::Distribution;
use strict;
use warnings;
use namespace::autoclean;
use Moose;
use ElasticSearchX::Model::Document;
use MetaCPAN::Types::TypeTiny qw( BugSummary RiverSummary );
use MetaCPAN::Util qw(true false);
has name => (
is => 'ro',
required => 1,
id => 1,
);
has bugs => (
is => 'ro',
isa => BugSummary,
dynamic => 1,
writer => '_set_bugs',
);
has river => (
is => 'ro',
isa => RiverSummary,
dynamic => 1,
writer => '_set_river',
default => sub {
+{
bucket => 0,
bus_factor => 1,
immediate => 0,
total => 0,
};
},
);
sub releases {
my $self = shift;
return $self->index->model->doc("release")
->query( { term => { "distribution" => $self->name } } );
}
sub set_first_release {
my $self = shift;
my @releases = $self->releases->sort( ["date"] )->all;
my $first = shift @releases;
$first->_set_first(true);
$first->put;
for my $rel (@releases) {
$rel->_set_first(false);
$rel->put;
}
return $first;
}
__PACKAGE__->meta->make_immutable;
1;