| 1 | # | ||||||||||||||||||||
| 2 | # $Id: Pivots.pm,v 58d7ce835577 2023/03/25 10:34:10 gomor $ | ||||||||||||||||||||
| 3 | # | ||||||||||||||||||||
| 4 | package OPP::Proc::Pivots; | ||||||||||||||||||||
| 5 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 1 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 1 | ▶ | use base qw(OPP::Proc); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | 1 | __PACKAGE__->cgBuildIndices; | |||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 1 | our $VERSION = '1.00'; | |||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | # | ||||||||||||||||||||
| 14 | # NOTE: pivots can handle both SCALAR & ARRAYs for all fields | ||||||||||||||||||||
| 15 | # | ||||||||||||||||||||
| 16 | # | pivots | ||||||||||||||||||||
| 17 | # | pivots domain,subject.organization,subject.email | ||||||||||||||||||||
| 18 | # | ||||||||||||||||||||
| 19 | sub process { | ||||||||||||||||||||
| 20 | 0 | ▶ | my $self = shift; | ||||||||||||||||||
|
Subroutine
process: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||
| 21 | 0 | my ($input) = @_; | |||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 0 | my $defaults = [ qw( | |||||||||||||||||||
| 24 | domain organization geolocus.netname netname subject.organization | ||||||||||||||||||||
| 25 | subject.email issuer.organization | ||||||||||||||||||||
| 26 | app.http.tracker.ga app.http.tracker.gaw app.http.tracker.gpub | ||||||||||||||||||||
| 27 | app.http.tracker.fbq app.http.tracker.snaptr | ||||||||||||||||||||
| 28 | ) ]; | ||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | 0 | my $rewrite = { | |||||||||||||||||||
| 31 | 'app.extract.domain' => 'domain', | ||||||||||||||||||||
| 32 | }; | ||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | 0 | my $options = $self->options; | |||||||||||||||||||
| 35 | 0 | ▶ | my $pivots = defined($options->{0}) ? [ split(',', $options->{0}) ] : $defaults; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | 0 | my %pivots = map { $_ => 1 } @$pivots; | |||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | 0 | for my $field (keys %$input) { | |||||||||||||||||||
| 40 | 0 | ▶ | next unless $pivots{$field}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 41 | 0 | ▶ | my $v = $self->value($input, $field) or next; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 42 | 0 | ▶ | next unless @$v; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 43 | 0 | ▶ | $field = $rewrite->{$field} || $field; | ||||||||||||||||||
|
Condition0%0/3
$rewrite->{$field} || $field
MC/DC0%0/2
$rewrite->{$field} || $field
$rewrite->{$field}
$field
Truth table0%0/3
A || B
A= $rewrite->{$field}B= $field
| |||||||||||||||||||||
| 44 | 0 | for (@$v) { | |||||||||||||||||||
| 45 | 0 | ▶ | $self->output->add({ $field => $_ }) unless $self->state->exists("$field|$_", $self->idx); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 46 | 0 | $self->state->add("$field|$_", 1, $self->idx); | |||||||||||||||||||
| 47 | } | ||||||||||||||||||||
| 48 | } | ||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | 0 | return 1; | |||||||||||||||||||
| 51 | } | ||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | 1 | 1; | |||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | __END__ | ||||||||||||||||||||