Branch Coverage

blib/lib/SeeAlso/Source/BeaconAggregator/Maintenance.pm
Criterion Covered Total %
branch 436 750 58.1


line true false branch
211 9 0 unless exists $options{'verbose'}
215 0 9 unless my $hdl = $self->{'dbh'}
218 0 9 unless $hdl->do("CREATE TABLE IF NOT EXISTS repos (\n seqno INTEGER PRIMARY KEY AUTOINCREMENT,\n alias TEXT,\n sort TEXT,\n uri VARCHAR(512),\n ruri VARCHAR(512),\n mtime INTEGER,\n utime INTEGER,\n ftime INTEGER,\n counti INTEGER DEFAULT 0,\n countu INTEGER DEFAULT 0,\n fstat TEXT,\n ustat TEXT,\n admin VARCHAR(512),\n @bf\n);\n")
238 0 9 unless $hdl->do('CREATE UNIQUE INDEX IF NOT EXISTS seqnos ON repos(seqno);')
239 0 9 unless $hdl->do('CREATE INDEX IF NOT EXISTS aliases ON repos(alias);')
241 0 9 unless $hdl->do("CREATE TABLE IF NOT EXISTS beacons (\n hash CHARACTER(64) NOT NULL,\n seqno INTEGER REFERENCES repos(seqno) ON DELETE CASCADE,\n altid TEXT,\n hits INTEGER,\n info VARCHAR(255),\n link VARCHAR(1024) \n);\n")
255 0 9 unless $hdl->do('CREATE INDEX IF NOT EXISTS lookup ON beacons(hash);')
258 0 9 unless $hdl->do('CREATE UNIQUE INDEX IF NOT EXISTS mntnce ON beacons(seqno, hash, altid);')
262 0 9 unless $hdl->do("CREATE TRIGGER IF NOT EXISTS on_delete_seqno BEFORE DELETE ON repos FOR EACH ROW\n BEGIN\n DELETE FROM beacons WHERE seqno=OLD.seqno;\n END;\n")
271 0 9 unless $hdl->do("CREATE TABLE IF NOT EXISTS osd (\n key CHAR(20) NOT NULL,\n val VARCHAR(1024)\n);\n")
278 0 9 unless $hdl->do('CREATE INDEX IF NOT EXISTS OSDKeys ON osd(key);')
281 0 9 unless $hdl->do("CREATE TABLE IF NOT EXISTS admin (\n key CHAR(20) PRIMARY KEY NOT NULL,\n val VARCHAR(1024)\n);\n")
289 0 9 unless $hdl->do('CREATE UNIQUE INDEX IF NOT EXISTS ADMKeys ON admin(key);')
296 1 8 if ($dbver != $goalver) { }
0 8 elsif ($options{'verbose'}) { }
299 1 0 if ($dbver < 2)
309 1 8 unless ($dbver == $goalver)
311 0 1 unless $verh->execute($verkey, $goalver)
315 3 6 unless (exists $options{'identifierClass'})
316 1 2 if exists $self->{'identifierClass'}
320 5 4 if (exists $options{'identifierClass'} and my $wanttype = ref $options{'identifierClass'}) { }
2 4 elsif (exists $options{'identifierClass'} and not $options{'identifierClass'}) { }
321 1 4 if (exists $self->{'identifierClass'} and ref $self->{'identifierClass'} ne $wanttype)
323 2 2 if (my $oldtype = $admref->{$ickey}) { }
324 0 2 unless $oldtype eq $wanttype
328 0 2 if $options{'verbose'}
330 0 2 unless $ichdl->execute($ickey, $wanttype)
336 0 2 if $options{'verbose'}
338 0 2 unless $ichdl->execute($ickey)
344 0 8 if (exists $options{'prepareRedirs'} or exists $admref->{$rikey})
346 0 0 if ($options{'prepareRedirs'} or $admref->{$rikey} and not exists $options{'prepareRedirs'}) { }
0 0 elsif (not $admref->{$rikey} && ($options{'prepareRedirs'} || !exists $options{'prepareRedirs'})) { }
347 0 0 if $options{'prepareRedirs'} and $options{'verbose'}
348 0 0 unless $hdl->do('CREATE INDEX IF NOT EXISTS redir ON beacons(altid,seqno);')
349 0 0 unless $rihdl->execute($rikey, 1)
353 0 0 if $options{'verbose'}
354 0 0 unless $hdl->do('DROP INDEX IF EXISTS redir;')
355 0 0 unless $rihdl->execute($rikey, 0)
361 0 8 if $options{'verbose'}
363 0 8 if $options{'verbose'}
376 0 1 unless my $hdl = $self->{'dbh'}
379 0 1 unless $hdl->do('VACUUM')
381 0 1 unless $hdl->do('REINDEX')
383 0 1 unless $hdl->do('ANALYZE;')
440 1 8 unless exists $options{'verbose'}
443 0 9 if (not $file) { }
0 9 elsif (not -e $file) { }
0 9 elsif (not -r _) { }
0 9 elsif (-z _) { }
454 0 9 unless open BKN, '<:utf8', $file
457 9 0 unless (defined $self->{'identifierClass'})
459 0 9 if $options{'verbose'} and ref $package
462 0 9 unless $fields
465 1 8 unless $fields->{'_uri'}
466 0 9 unless $fields->{'_alias'}
470 4 5 if ($options{'verbose'})
482 9 111 unless ($linecount++)
483 0 9 if (s/^\x{FEFF}//) { }
0 9 elsif (s/^\xef\xbb\xbf//) { }
488 0 9 if (/^\s*$/)
493 65 55 if (not defined $collno) { }
494 55 10 if (/^#\s*([A-Z][\w-]*):\s*(.*)$/) { }
0 10 elsif (/^(#[^:\s]+)/) { }
1 9 elsif (/^\s*$/) { }
0 9 elsif (not $headerseen) { }
497 0 55 if $field =~ s/^DATE$/TIMESTAMP/
499 0 55 if $data =~ /^\s*$/
500 52 3 if ('SeeAlso::Source::BeaconAggregator'->beaconfields($field)) { }
501 0 52 if ($fields->{$field}) { }
513 1 0 if $options{'verbose'}
520 0 9 unless ($collno)
533 55 0 if $id
534 0 55 unless $id
536 14 41 if ($options{'filter'})
538 7 7 unless ($id)
540 0 7 unless (++$reccount % 10000)
542 0 0 if $options{'verbose'}
551 18 30 if (@rest and $rest[$#rest] =~ m[^\S+://\S+$]) { }
0 30 elsif (defined $rest[2]) { }
556 9 39 if (@rest and $rest[0] =~ /^\d*$/) { }
1 38 elsif (defined $rest[1]) { }
30 8 elsif (defined $rest[0]) { }
559 1 8 if (not $altid || $link and $format =~ /\baltTARGET\b/) { }
568 1 0 if (not $altid || $link and $format =~ /\baltTARGET\b/) { }
581 0 48 if (@rest)
584 30 18 unless ($link)
585 28 2 if ($format =~ /\bhasTARGET\b/) { }
2 0 elsif ($format =~ /\baltTARGET\b/) { }
0 0 elsif ($format =~ /\bnoTARGET\b/) { }
588 2 0 if ($altid) { }
0 0 elsif ($info) { }
591 0 0 defined $hits ? :
599 0 0 defined $hits ? :
0 0 if $options{'verbose'} > 1
604 0 0 defined $hits ? :
610 4 44 unless ($format =~ /\baltTARGET\b/)
613 8 40 unless defined $hits
614 0 48 if $hits =~ /^0+/
615 40 8 if $hits eq ''
618 0 48 if (defined $self->{'identifierClass'}) { }
620 0 0 unless ($self->{'identifierClass'}->valid)
621 0 0 if $options{'verbose'}
630 24 24 if ($replacehandle and $did = $replacehandle->execute($hits, $info, $link, $hash, $altid)) { }
24 0 elsif ($did = $inserthandle->execute($hash, $altid, $hits, $info, $link)) { }
0 0 elsif ($inserthandle->errstr =~ /constraint/) { }
631 0 24 if ($replacehandle->err) { }
19 5 elsif ($did eq '0E0') { }
637 6 13 if ($did eq '0E0') { }
639 0 6 if ($altid) { }
640 0 0 if $options{'verbose'}
642 0 6 if $options{'verbose'} > 1
651 7 17 if ($did eq '0E0') { }
653 0 7 if $options{'verbose'} > 1
660 0 0 if $options{'verbose'} > 1
665 0 48 unless (++$reccount % 10000)
667 0 0 if $options{'verbose'}
672 0 9 unless (defined $collno)
673 0 0 if ($headerseen) { }
0 0 elsif ($.) { }
675 0 0 if ($collno) { }
693 9 0 if ($autopurge)
695 4 5 if ($oseq)
697 0 4 if $ENV{'DBI_PROFILE'}
698 0 4 unless my $rows = $bcdelh->execute($oseq)
700 0 4 if $options{'verbose'}
701 3 1 if $rows eq '0E0'
707 0 9 if $ENV{'DBI_PROFILE'}
708 0 9 unless my $rows = $rpdelh->execute($autopurge, $collno)
710 5 4 if $rows eq '0E0'
711 4 5 if $options{'verbose'}
721 8 1 $recnew || $recdel ? :
746 0 9 if $recok != $counti
747 1 8 unless ($numchg)
749 0 1 if $fields->{'_counti'} != $counti
754 8 1 $numchg ? :
755 0 9 if $ENV{'DBI_PROFILE'}
757 0 9 unless $updh->execute($counti, $countu, $statline, time, 'successfully loaded', $sort, $collno)
760 9 0 if ($numchg or $options{'force'})
767 0 9 if ($options{'nostat'}) { }
807 9 0 if (my $alias = $fieldref->{'_alias'})
810 0 9 if $ENV{'DBI_PROFILE'}
811 0 9 unless $listh->execute($alias)
814 9 4 unless defined $row
817 0 4 if ($options{'verbose'}) { }
818 0 0 unless $osq
825 4 5 if ($rowcnt and $rowcnt == 1)
826 2 2 if $ocounti
827 2 2 if $ocountu
832 0 9 if ($fieldref->{'FORMAT'} and $self->{'accept'}{'FORMAT'}) { }
8 1 elsif ($fieldref->{'FORMAT'}) { }
1 0 elsif ($fieldref->{'VERSION'} or $fieldref->{'TARGET'} or $fieldref->{'PREFIX'} or $fieldref->{'MESSAGE'}) { }
0 0 elsif ($self->{'accept'}{'FORMAT'}) { }
833 0 0 if ($fieldref->{'FORMAT'} =~ /$self->{'accept'}{'FORMAT'}/) { }
847 0 9 if ($fieldref->{'FORMAT'} and $fieldref->{'FORMAT'} =~ /v(?:ersion)?\s*(\d+(?:\.\d*)?)/i)
849 2 7 unless ($fieldref->{'VERSION'})
850 1 1 $fieldref->{'FORMAT'} ? :
853 0 9 if ($self->{'accept'}{'VERSION'})
855 0 0 unless $fieldref->{'VERSION'} =~ /$self->{'accept'}{'VERSION'}/
858 7 2 if ($fieldref->{'ALTTARGET'})
859 0 7 unless defined $fieldref->{'ALTTARGET'}
861 7 0 if ($parsed and $parsed =~ /(^|[^%])(%.)*%\d\$s/) { }
0 0 elsif ($parsed) { }
865 0 7 unless $parsed =~ /(^|[^%])(%.)*%2\$s/
878 0 9 if ($fieldref->{'IMGTARGET'})
879 0 0 unless defined $fieldref->{'IMGTARGET'}
881 0 0 if ($parsed and $parsed =~ /(^|[^%])(%.)*%\d\$s/) { }
0 0 elsif ($parsed) { }
894 9 0 if (exists $fieldref->{'TARGET'}) { }
0 0 elsif ($format =~ /^BEACON/) { }
895 0 9 unless defined $fieldref->{'TARGET'}
897 8 1 if ($parsed and $parsed =~ /(^|[^%])(%.)*%1\$s/ and not $parsed =~ /(^|[^%])(%.)*%[2-9]\$s/) { }
1 0 elsif ($parsed) { }
902 0 1 if (exists $fieldref->{'ALTTARGET'}) { }
926 0 9 if $fieldref->{'MESSAGE'}
928 1 8 if ($fieldref->{'TIMESTAMP'}) { }
929 1 0 if (my $parsed = hDecode($fieldref, 'TIMESTAMP')) { }
930 1 0 if $options{'verbose'}
943 0 9 if ($fieldref->{'REVISIT'}) { }
944 0 0 if (my $parsed = hDecode($fieldref, 'REVISIT')) { }
945 0 0 if ($parsed < $^T) { }
948 0 0 if $options{'verbose'}
964 0 21 if (s/^ERROR: //)
966 0 0 if $err
970 0 0 unless ($cancontinue or $options{'ignore-header-errors'})
976 1 8 unless $fieldref->{'_uri'}
982 4 105 unless defined $val
984 54 51 if ($dbkey = 'SeeAlso::Source::BeaconAggregator'->beaconfields($key)) { }
51 0 elsif ($key =~ /_(\w+)$/) { }
991 82 23 unless ($myval =~ /^\d+$/)
1001 0 9 if $ENV{'DBI_PROFILE'}
1002 0 9 unless $sth->execute
1006 4 5 if ($osq)
1096 2 7 unless $params
1097 5 4 unless exists $options{'verbose'}
1100 9 0 unless ($ua)
1102 0 9 unless $ua = 'LWP::UserAgent'->new('agent', 'SA-S-BeaconAggregator ', 'env_proxy', 1, 'timeout', 300)
1109 1 8 $sq_or_alias =~ /^\d+$/ ? :
1114 0 9 if $ENV{'DBI_PROFILE'}
1115 0 9 unless $ssth->execute(@cval)
1116 0 9 if $ssth->err
1118 5 4 $aryref ? :
1121 0 9 unless $uri
1125 4 5 if $options{'verbose'}
1126 0 9 unless my $rq = 'HTTP::Request'->new('GET', $uri, ['Accept', 'text/*'])
1127 1 4 if ($fetchtime and $modtime and not $options{'force'})
1128 0 1 if $options{'verbose'}
1131 9 0 if ($rq->can('accept_decodable')) { }
1134 0 0 if $options{'verbose'} and not $lwpcarp817++
1139 0 9 if $uri ne $nuri
1140 8 1 if ($response->is_success) { }
1 0 elsif ($response->code == 304) { }
1141 4 4 $osq ? :
1144 8 0 if ($response->can('content_charset')) { }
1146 4 4 if $charset and $options{'verbose'}
1149 0 0 if $options{'verbose'} and not $lwpcarp827++
1153 4 4 if $lm and $options{'verbose'}
1157 4 4 if $vt and $options{'verbose'}
1161 0 8 unless my($tmpfh, $tmpfile) = File::Temp::tempfile('BeaconAggregator-XXXXXXXX', 'SUFFIX', '.txt', 'TMPDIR', 1)
1163 0 8 unless ($response->content_is_text)
1166 0 0 if (my $ce = $response->content_encoding)
1169 0 0 if ($ct =~ s[^(.+\/)?($ctt)$][$2])
1182 0 8 if ($$contref =~ /^\x{FFEF}/) { }
0 8 elsif ($$contref =~ s/^\xef\xbb\xbf//) { }
7 1 elsif (utf8::is_utf8($$contref)) { }
1 0 elsif (utf8::decode($$contref)) { }
1188 0 0 utf8::is_utf8($$contref) ? :
1190 0 0 if utf_deduplicate($contref)
1193 3 4 if $options{'verbose'}
1198 1 0 if $options{'verbose'}
1211 0 8 if (not $collno and $osq)
1215 0 0 $statref ? :
0 0 if $ENV{'DBI_PROFILE'}
1217 0 0 $statref ? :
0 0 unless $usth->execute(time, $statref ? "load error: $statref" : 'internal error', $osq)
1220 8 0 if -f $tmpfile
1221 8 0 $collno ? :
1224 0 1 if $options{'verbose'}
1226 0 1 if $options{'verbose'}
1230 0 1 if $ENV{'DBI_PROFILE'}
1232 0 1 unless $usth->execute(time, $response->status_line, $nuri, $osq)
1238 0 0 unless $osq
1242 0 0 if $ENV{'DBI_PROFILE'}
1244 0 0 unless $usth->execute(time, $response->status_line, $nuri, $osq)
1253 7 0 if (utf8::downgrade($$stringref, 1)) { }
1255 0 7 utf8::is_utf8($$stringref) ? :
1259 0 0 utf8::is_utf8($$stringref) ? :
1260 0 0 if $newlength == $prevlength
1295 3 0 unless exists $options{'verbose'}
1298 0 3 if ($seqno_or_alias and $seqno_or_alias =~ /^\d+$/) { }
3 0 elsif ($seqno_or_alias or $options{'force'}) { }
1301 3 0 $seqno_or_alias ? :
1302 0 3 unless (@seqnos)
1306 0 3 unless ($options{'force'} or @seqnos == 1)
1316 0 3 if ($options{'force'})
1321 0 0 if $ENV{'DBI_PROFILE'}
1322 0 0 unless my $rows = $sth->execute($seqno_or_alias)
1323 0 0 if $options{'verbose'}
1331 0 3 if $ENV{'DBI_PROFILE'}
1332 0 3 unless my $rows = $sth->execute(@cval)
1333 0 3 if $rows eq '0E0'
1335 3 0 if ($rows or $options{'force'})
1342 0 3 if ($options{'nostat'}) { }
1381 2 0 unless exists $options{'verbose'}
1383 0 2 if ($seqno_or_alias and $seqno_or_alias =~ /^\d+$/) { }
2 0 elsif ($seqno_or_alias or $options{'force'}) { }
1386 2 0 $seqno_or_alias ? :
1387 0 2 unless (@seqnos)
1391 0 2 unless ($options{'force'} or @seqnos == 1)
1408 0 2 if $ENV{'DBI_PROFILE'}
1409 0 2 unless my $rows = $sth->execute($seqno)
1410 0 2 if $rows eq '0E0'
1411 0 2 if $options{'verbose'}
1413 0 2 if $ENV{'DBI_PROFILE'}
1415 0 2 unless $usth->execute(0, 0, time, 'purged', $seqno)
1418 2 0 if ($trows or $options{'force'})
1425 0 2 if ($options{'nostat'}) { }
1451 4 5 if ($dbkey = 'SeeAlso::Source::BeaconAggregator'->beaconfields($key)) { }
5 0 elsif ($key =~ /_(\w+)$/) { }
1465 0 9 if $ENV{'DBI_PROFILE'}
1466 0 9 unless $osth->execute(@cval)
1468 7 2 defined $_->[0] ? :
1471 3 6 if (defined $value and $value ne '') { }
0 6 elsif (defined $value) { }
1476 0 3 if $ENV{'DBI_PROFILE'}
1477 0 3 unless $rows = $usth->execute($value, @cval)
1483 0 0 if $ENV{'DBI_PROFILE'}
1484 0 0 unless $rows = $dsth->execute(undef, @cval)
1513 1 4 unless ($self->{'_iterator_info'})
1518 0 1 if $ENV{'DBI_PROFILE'}
1519 0 1 unless $sth->execute(@cval)
1524 1 4 unless (defined $info)
1525 0 1 if $self->{'_iterator_info'}->err
1534 65 71 unless defined $val
1537 25 46 if ($key =~ /^bc(\w+)$/) { }
1558 7 21 unless ($self->{'_iterator_listCollections'})
1563 0 7 if $ENV{'DBI_PROFILE'}
1564 0 7 unless $sth->execute(@cval)
1568 7 21 unless ($onerow)
1569 0 7 if $self->{'_iterator_listCollections'}->err
1599 61 0 unless exists $options{'verbose'}
1601 17 44 if ($seqno_or_alias and $seqno_or_alias =~ /^\d+$/) { }
4 40 elsif ($seqno_or_alias) { }
1605 4 0 if (@seqnos) { }
1615 28 33 $options{'distinct'} ? :
1620 0 61 if $ENV{'DBI_PROFILE'}
1621 0 61 unless $sth->execute
1649 0 64 $pattern ? :
1650 32 32 $options{'distinct'} ? :
1651 8 56 unless ($self->{'_iterator_idCounts'})
1655 0 8 if $ENV{'DBI_PROFILE'}
1656 0 8 unless $sth->execute
1658 2 6 unless (defined $self->{'identifierClass'})
1660 0 2 if $options{'verbose'} and ref $package
1664 8 56 unless ($onerow)
1665 0 8 if $self->{'_iterator_idCounts'}->err
1669 42 14 if (defined $self->{'identifierClass'})
1674 14 28 $c->can('pretty') ? :
1698 12 0 $pattern =~ /%/ ? :
12 32 $pattern ? :
1700 8 36 unless ($self->{'_iterator_idList_handle'})
1704 0 0 $pattern ? :
0 8 if $ENV{'DBI_PROFILE'}
1705 4 4 $pattern ? :
0 8 unless $sth->execute($pattern ? $pattern : ())
1709 2 6 unless defined $self->{'identifierClass'}
1711 8 36 unless (exists $self->{'_iterator_idList_prefetch'})
1719 32 16 unless $onerow->[2]
1720 12 36 unless defined $onerow->[3]
1721 44 4 unless defined $onerow->[4]
1722 0 48 unless defined $onerow->[5]
1723 36 12 if (defined $self->{'identifierClass'})
1728 12 24 $c->can('pretty') ? :
1730 40 8 if ($pf) { }
1731 12 28 if ($pf->[0] eq $onerow->[0]) { }
1744 0 8 if ($self->{'_iterator_idList_handle'}->err)
1748 8 0 $pf ? :
1762 2 3 unless $self->clearOSD($_[0])
1763 2 1 defined $_[1] ? :
1774 2 6 unless $field
1775 2 4 unless defined $self->osdKeys($field)
1779 0 4 if $ENV{'DBI_PROFILE'}
1780 0 4 unless $sth->execute($field)
1792 1 9 unless $field
1793 1 8 unless @values
1794 1 7 unless defined $self->osdKeys($field)
1798 0 7 if $ENV{'DBI_PROFILE'}
1800 0 7 unless my $tuples = $sth->execute_array({'ArrayTupleStatus', $tstatus}, $field, \@values)
1817 2 2 unless $self->clearBeaconMeta(@_)
1818 1 1 defined $_[1] ? :
1829 2 5 unless $rfield
1830 2 3 unless my $field = $self->beaconfields($rfield)
1834 0 3 if $ENV{'DBI_PROFILE'}
1835 0 3 unless $sth->execute($field)
1846 1 6 unless $rfield
1847 1 5 unless my $field = $self->beaconfields($rfield)
1851 0 5 if $ENV{'DBI_PROFILE'}
1852 0 5 unless $sth->execute($field, $value)
1871 2 31 unless $field
1873 1 30 unless defined $value
1876 0 30 if $ENV{'DBI_PROFILE'}
1877 0 30 unless $admh->execute($field, $value)
1879 27 3 defined $retval ? :
1887 0 20 unless $fnam
1888 17 3 ref $val ? :
1889 0 20 unless defined $_
1891 16 4 if ($fnam =~ /target$/i) { }
0 4 elsif ($fnam =~ /message$/i) { }
2 2 elsif ($fnam =~ /time|revisit/i) { }
1894 1 1 if (/^\d+$/) { }
1 0 elsif (my $p = &HTTP::Date::str2time($_, 'GMT')) { }
1908 0 79 ref $val ? :
1909 0 79 unless defined $_
1910 15 64 if ($fnam =~ /time|revisit/i) { }
2 62 elsif ($fnam =~ /message/i) { }
6 56 elsif ($fnam =~ /target/i) { }