line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bootylicious::ArticlePager; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
502
|
use strict; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
131
|
|
4
|
5
|
|
|
5
|
|
21
|
use warnings; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
110
|
|
5
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
21
|
use base 'Mojo::Base'; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
301
|
|
7
|
|
|
|
|
|
|
|
8
|
5
|
|
|
5
|
|
363
|
use Bootylicious::Timestamp; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
29
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
__PACKAGE__->attr('timestamp'); |
11
|
|
|
|
|
|
|
__PACKAGE__->attr(limit => 10); |
12
|
|
|
|
|
|
|
__PACKAGE__->attr('iterator'); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub prev { |
15
|
6
|
|
|
6
|
0
|
14
|
my $self = shift; |
16
|
|
|
|
|
|
|
|
17
|
6
|
|
|
|
|
18
|
my $i = $self->iterator; |
18
|
|
|
|
|
|
|
|
19
|
6
|
|
|
|
|
32
|
my $first = $self->articles->first; |
20
|
|
|
|
|
|
|
|
21
|
6
|
|
|
|
|
21
|
$i->rewind; |
22
|
6
|
|
|
|
|
24
|
while (my $article = $i->next) { |
23
|
8
|
100
|
|
|
|
28
|
if ($article->created->epoch == $first->created->epoch) { |
24
|
5
|
|
|
|
|
37
|
return $i->prev($self->limit)->last; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
|
|
2
|
return; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub prev_timestamp { |
32
|
5
|
|
|
5
|
0
|
4721
|
my $self = shift; |
33
|
|
|
|
|
|
|
|
34
|
5
|
|
|
|
|
20
|
my $prev = $self->prev; |
35
|
5
|
50
|
|
|
|
38
|
return '' unless $prev; |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
0
|
return $prev->created->timestamp; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub next { |
41
|
6
|
|
|
6
|
0
|
483
|
my $self = shift; |
42
|
|
|
|
|
|
|
|
43
|
6
|
|
|
|
|
19
|
my $i = $self->iterator; |
44
|
|
|
|
|
|
|
|
45
|
6
|
|
|
|
|
31
|
my $last = $self->articles->last; |
46
|
|
|
|
|
|
|
|
47
|
6
|
|
|
|
|
21
|
$i->rewind; |
48
|
6
|
|
|
|
|
16
|
while (my $article = $i->next) { |
49
|
12
|
100
|
|
|
|
33
|
last if $article->created->epoch == $last->created->epoch; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
6
|
|
|
|
|
37
|
return $i->next; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub next_timestamp { |
56
|
5
|
|
|
5
|
0
|
328
|
my $self = shift; |
57
|
|
|
|
|
|
|
|
58
|
5
|
|
|
|
|
56
|
my $next = $self->next; |
59
|
5
|
100
|
|
|
|
30
|
return '' unless $next; |
60
|
|
|
|
|
|
|
|
61
|
1
|
|
|
|
|
3
|
return $next->created->timestamp; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub articles { |
65
|
31
|
|
|
31
|
0
|
1232
|
my $self = shift; |
66
|
|
|
|
|
|
|
|
67
|
31
|
100
|
|
|
|
151
|
return $self->{articles} if $self->{articles}; |
68
|
|
|
|
|
|
|
|
69
|
10
|
|
|
|
|
41
|
my $i = $self->iterator; |
70
|
|
|
|
|
|
|
|
71
|
10
|
100
|
|
|
|
61
|
if ($self->timestamp) { |
72
|
1
|
|
|
|
|
7
|
while (my $article = $i->next) { |
73
|
|
|
|
|
|
|
last |
74
|
4
|
100
|
|
|
|
12
|
if $article->created->epoch |
75
|
|
|
|
|
|
|
<= Bootylicious::Timestamp->new(timestamp => $self->timestamp)->epoch; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
10
|
|
|
|
|
77
|
$i->prev; |
80
|
|
|
|
|
|
|
|
81
|
10
|
|
|
|
|
69
|
return $self->{articles} = $i->next($self->limit); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |