line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package GitHub::MergeVelocity::Repository::PullRequest; |
2
|
|
|
|
|
|
|
$GitHub::MergeVelocity::Repository::PullRequest::VERSION = '0.000006'; |
3
|
3
|
|
|
3
|
|
62276
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
97
|
|
4
|
3
|
|
|
3
|
|
13
|
use warnings; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
68
|
|
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
2562
|
use DateTime; |
|
3
|
|
|
|
|
427387
|
|
|
3
|
|
|
|
|
151
|
|
7
|
3
|
|
|
3
|
|
1589
|
use GitHub::MergeVelocity::Types qw( Datetime ); |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
37
|
|
8
|
3
|
|
|
3
|
|
1945
|
use Math::Round qw( round ); |
|
3
|
|
|
|
|
1681
|
|
|
3
|
|
|
|
|
191
|
|
9
|
3
|
|
|
3
|
|
975
|
use Moo; |
|
3
|
|
|
|
|
17302
|
|
|
3
|
|
|
|
|
18
|
|
10
|
3
|
|
|
3
|
|
4302
|
use MooX::StrictConstructor; |
|
3
|
|
|
|
|
18574
|
|
|
3
|
|
|
|
|
19
|
|
11
|
3
|
|
|
3
|
|
37192
|
use Types::Standard qw( Bool Int Str ); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
54
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has age => ( |
14
|
|
|
|
|
|
|
is => 'ro', |
15
|
|
|
|
|
|
|
init_arg => undef, |
16
|
|
|
|
|
|
|
isa => Int, |
17
|
|
|
|
|
|
|
lazy => 1, |
18
|
|
|
|
|
|
|
builder => '_build_age', |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has closed_at => ( |
22
|
|
|
|
|
|
|
is => 'ro', |
23
|
|
|
|
|
|
|
isa => Datetime, |
24
|
|
|
|
|
|
|
predicate => 'is_closed', |
25
|
|
|
|
|
|
|
coerce => 1, |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
has created_at => ( |
29
|
|
|
|
|
|
|
is => 'ro', |
30
|
|
|
|
|
|
|
isa => Datetime, |
31
|
|
|
|
|
|
|
predicate => 'has_created_at', |
32
|
|
|
|
|
|
|
coerce => 1, |
33
|
|
|
|
|
|
|
required => 1, |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has is_work_in_progress => ( |
37
|
|
|
|
|
|
|
is => 'ro', |
38
|
|
|
|
|
|
|
isa => Bool, |
39
|
|
|
|
|
|
|
lazy => 1, |
40
|
|
|
|
|
|
|
default => sub { |
41
|
|
|
|
|
|
|
return shift->title =~ m{\A\[?WIP\]?}; |
42
|
|
|
|
|
|
|
}, |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
has merged_at => ( |
46
|
|
|
|
|
|
|
is => 'ro', |
47
|
|
|
|
|
|
|
isa => Datetime, |
48
|
|
|
|
|
|
|
predicate => 'is_merged', |
49
|
|
|
|
|
|
|
coerce => 1, |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
has number => ( |
53
|
|
|
|
|
|
|
is => 'ro', |
54
|
|
|
|
|
|
|
isa => Int, |
55
|
|
|
|
|
|
|
required => 1, |
56
|
|
|
|
|
|
|
documentation => 'issue number in the GitHub url' |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
has title => ( |
60
|
|
|
|
|
|
|
is => 'ro', |
61
|
|
|
|
|
|
|
isa => Str, |
62
|
|
|
|
|
|
|
required => 1, |
63
|
|
|
|
|
|
|
); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
has state => ( |
66
|
|
|
|
|
|
|
is => 'ro', |
67
|
|
|
|
|
|
|
isa => Str, |
68
|
|
|
|
|
|
|
init_arg => undef, |
69
|
|
|
|
|
|
|
lazy => 1, |
70
|
|
|
|
|
|
|
builder => '_build_state', |
71
|
|
|
|
|
|
|
); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
has velocity => ( |
74
|
|
|
|
|
|
|
is => 'ro', |
75
|
|
|
|
|
|
|
isa => Int, |
76
|
|
|
|
|
|
|
init_arg => undef, |
77
|
|
|
|
|
|
|
lazy => 1, |
78
|
|
|
|
|
|
|
builder => '_build_velocity', |
79
|
|
|
|
|
|
|
); |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub is_open { |
82
|
16
|
|
|
16
|
0
|
18
|
my $self = shift; |
83
|
16
|
|
|
|
|
246
|
return $self->state eq 'open'; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub _build_age { |
87
|
18
|
|
|
18
|
|
2619
|
my $self = shift; |
88
|
|
|
|
|
|
|
|
89
|
18
|
100
|
|
|
|
65
|
my $upper_bound |
|
|
100
|
|
|
|
|
|
90
|
|
|
|
|
|
|
= $self->is_merged ? $self->merged_at |
91
|
|
|
|
|
|
|
: $self->is_closed ? $self->closed_at |
92
|
|
|
|
|
|
|
: DateTime->now; |
93
|
|
|
|
|
|
|
|
94
|
18
|
|
|
|
|
331
|
return $upper_bound->delta_days( $self->created_at )->delta_days; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub _build_state { |
98
|
16
|
|
|
16
|
|
7249
|
my $self = shift; |
99
|
|
|
|
|
|
|
return |
100
|
16
|
100
|
|
|
|
283
|
$self->is_merged ? 'merged' |
|
|
100
|
|
|
|
|
|
101
|
|
|
|
|
|
|
: $self->is_closed ? 'closed' |
102
|
|
|
|
|
|
|
: 'open'; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
# add points for merges in the first 30 days |
106
|
|
|
|
|
|
|
# merges in 31 - 45 are neutral |
107
|
|
|
|
|
|
|
# subtract after 45 days |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub _build_velocity { |
110
|
18
|
|
|
18
|
|
3102
|
my $self = shift; |
111
|
|
|
|
|
|
|
|
112
|
18
|
100
|
|
|
|
252
|
return 0 if $self->is_work_in_progress; |
113
|
|
|
|
|
|
|
|
114
|
16
|
100
|
|
|
|
271
|
if ( $self->is_open ) { |
115
|
1
|
50
|
|
|
|
22
|
return $self->age > 45 ? 45 - $self->age : 0; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
15
|
|
|
|
|
111
|
my $score = 0; |
119
|
15
|
100
|
|
|
|
211
|
if ( $self->age < 31 ) { |
|
|
100
|
|
|
|
|
|
120
|
13
|
|
|
|
|
322
|
$score += round( 1.2**( 31 - $self->age ) ); |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
elsif ( $self->age > 45 ) { |
123
|
1
|
|
|
|
|
43
|
$score = 45 - $self->age; |
124
|
|
|
|
|
|
|
} |
125
|
15
|
|
|
|
|
523
|
return $score; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
1; |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=pod |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=encoding UTF-8 |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 NAME |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
GitHub::MergeVelocity::Repository::PullRequest - Encapsulate select data about GitHub pull requests |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 VERSION |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
version 0.000006 |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 AUTHOR |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Olaf Alders <olaf@wundercounter.com> |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
This software is copyright (c) 2015 by Olaf Alders. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
151
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=cut |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
__END__ |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
# ABSTRACT: Encapsulate select data about GitHub pull requests |