| 1 | package IronMan::Schema::ResultSet::Feed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use base 'DBIx::Class::ResultSet'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use Data::UUID; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use Scalar::Util 'blessed'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | ## Need to check if url is duplicated by normalising it as well as just uniquing what is passed in! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 0 | ▶ | sub add_new_blog { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_new_blog: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 0 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | # print STDERR "Add new blog: ", Data::Dumper::Dumper(\%args ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | my $uuids = Data::UUID->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | my $fdb = $self->find_or_new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | ({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | id => $uuids->create_str, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | url => $args{url}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | title => $args{title}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | owner => $args{email}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | { key => 'url' } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | if($fdb->in_storage) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | return (0, $fdb); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | $fdb->insert; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | return (1, $fdb); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | ## Given a feed url that should exist as a unique feed in the db, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | ## and an arrayref of entry hashes/objects, return ones we dont | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | ## have yet. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | sub filter_unseen { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
filter_unseen: not called CC=11 SCAR=48.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | my ($self, $feed_url, $entries) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | die "filter_unseen not passed a feed_url" if(!$feed_url); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | return [] if(!$entries || ref($entries) ne 'ARRAY' || !@$entries); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not $entries or ref $entries ne "ARRAY" or not @$entries
not $entries or ref $entries ne "ARRAY"
MC/DC0%0/3
not $entries or ref $entries ne "ARRAY" or not @$entries
not $entries
ref $entries ne "ARRAY"
not @$entries
Truth table0%0/4
not(A) or B or not(C)
A= not $entriesB= ref $entries ne "ARRAY"C= not @$entries
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | my $feed = $self->find({ url => $feed_url}, { key => 'url' }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | die "No such feed: $feed_url" if(!$feed); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | my %entry_urls = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | blessed($_) ? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | ( $_->can('url') && $_->url ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | ( $_->can('link') && $_->link ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | : $_->{url} => $_ } @$entries; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$_->can("url") and $_->url or $_->can("link") and $_->link
$_->can("url") and $_->url
$_->can("link") and $_->link
MC/DC0%0/4
$_->can("url") and $_->url or $_->can("link") and $_->link
$_->can("url")
$_->url
$_->can("link")
$_->link
Truth table0%0/7
A and B or C and D
A= $_->can("url")B= $_->urlC= $_->can("link")D= $_->link
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | my @got_these = $feed->posts->search({ url => { -in => [ keys %entry_urls ] } }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | delete $entry_urls{$_->url} for @got_these; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | return [ values(%entry_urls) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||