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