line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package GitHub::MergeVelocity::Repository::PullRequest; |
2
|
|
|
|
|
|
|
$GitHub::MergeVelocity::Repository::PullRequest::VERSION = '0.000007'; |
3
|
3
|
|
|
3
|
|
59855
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
112
|
|
4
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
161
|
|
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
2701
|
use DateTime; |
|
3
|
|
|
|
|
365843
|
|
|
3
|
|
|
|
|
141
|
|
7
|
3
|
|
|
3
|
|
1430
|
use GitHub::MergeVelocity::Types qw( Datetime ); |
|
3
|
|
|
|
|
12
|
|
|
3
|
|
|
|
|
41
|
|
8
|
3
|
|
|
3
|
|
2357
|
use Math::Round qw( round ); |
|
3
|
|
|
|
|
2309
|
|
|
3
|
|
|
|
|
252
|
|
9
|
3
|
|
|
3
|
|
1338
|
use Moo; |
|
3
|
|
|
|
|
20730
|
|
|
3
|
|
|
|
|
20
|
|
10
|
3
|
|
|
3
|
|
4936
|
use MooX::StrictConstructor; |
|
3
|
|
|
|
|
22909
|
|
|
3
|
|
|
|
|
22
|
|
11
|
3
|
|
|
3
|
|
44505
|
use Types::Standard qw( Bool Int Str ); |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
56
|
|
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
|
22
|
my $self = shift; |
83
|
16
|
|
|
|
|
253
|
return $self->state eq 'open'; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub _build_age { |
87
|
18
|
|
|
18
|
|
2554
|
my $self = shift; |
88
|
|
|
|
|
|
|
|
89
|
18
|
100
|
|
|
|
60
|
my $upper_bound |
|
|
100
|
|
|
|
|
|
90
|
|
|
|
|
|
|
= $self->is_merged ? $self->merged_at |
91
|
|
|
|
|
|
|
: $self->is_closed ? $self->closed_at |
92
|
|
|
|
|
|
|
: DateTime->now; |
93
|
|
|
|
|
|
|
|
94
|
18
|
|
|
|
|
285
|
return $upper_bound->delta_days( $self->created_at )->delta_days; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub _build_state { |
98
|
16
|
|
|
16
|
|
8690
|
my $self = shift; |
99
|
|
|
|
|
|
|
return |
100
|
16
|
100
|
|
|
|
268
|
$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
|
|
3038
|
my $self = shift; |
111
|
|
|
|
|
|
|
|
112
|
18
|
100
|
|
|
|
246
|
return 0 if $self->is_work_in_progress; |
113
|
|
|
|
|
|
|
|
114
|
16
|
100
|
|
|
|
275
|
if ( $self->is_open ) { |
115
|
1
|
50
|
|
|
|
21
|
return $self->age > 45 ? 45 - $self->age : 0; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
15
|
|
|
|
|
106
|
my $score = 0; |
119
|
15
|
100
|
|
|
|
241
|
if ( $self->age < 31 ) { |
|
|
100
|
|
|
|
|
|
120
|
13
|
|
|
|
|
331
|
$score += round( 1.2**( 31 - $self->age ) ); |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
elsif ( $self->age > 45 ) { |
123
|
1
|
|
|
|
|
40
|
$score = 45 - $self->age; |
124
|
|
|
|
|
|
|
} |
125
|
15
|
|
|
|
|
479
|
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.000007 |
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 |