ElasticSync/Role/ElasticBlackholeResult.pm

filter: Statementstmt 25.9% 14 / 54 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 36.3% 4 / 11 Podpod 0.0% 0 / 6 totaltotal 23.3% 18 / 77 CC 7 SCAR 18.3
CC
7
Cov
23%
es_index
12.0
es_obj_builder
12.0
es_build_id
6.0
CRAP 6.2
« ElasticSync/Role/ElasticSchema.pm ↑ Summary ElasticSync.pm »
1 package DBIx::Class::ElasticSync::Role::ElasticBlackholeResult;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use DateTime::Format::MySQL;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 0 ▶sub es_index {
Subroutine es_index: not called CC=3 SCAR=24.8
Pod undocumented
11  
12 0 my $self = shift;
13  
14 0 my $schema = $self->result_source->schema;
15 0 my $class = $self->result_source->source_name;
16  
17 0 my $elastic_rs = $schema->dispatcher->{$class};
18  
19 0 for my $rs (@$elastic_rs) {
20  
21 0 eval "use $rs";
22  
23 0 ▶ die $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
24  
25 0 my $obj = $self->es_obj_builder($rs);
26  
27 0 $self->schema->es_index_obj($obj);
28 }
29 }
30  
31 0 ▶sub es_obj_builder {
Subroutine es_obj_builder: not called CC=3 SCAR=24.8
Pod undocumented
32  
33 0 my $self = shift;
34 0 my $rs = shift;
35  
36 0 my $body = { $self->get_columns };
37  
38 0 for my $column ( $self->result_source->columns ) {
39  
40 0 ▶ if ( $self->result_source->column_info($column)->{es_blackhole_create_date} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->result_source->column_info($column)->{"es_blackhole_create_date"}) 0 0 0
41  
42 0 my $dt = DateTime->now;
43 0 $body->{$column} = DateTime::Format::MySQL->format_datetime($dt);
44 }
45 }
46  
47 0 my $obj = $rs->es_transform($body);
48  
49 0 $obj = { body => $body };
50 0 $obj->{type} = $rs->type;
51 0 $obj->{body}{es_id} = $self->es_build_id($rs);
52 0 $obj->{index} = $rs->index_name($obj);
53  
54 0 return $obj;
55  
56 }
57  
58 0 ▶sub es_build_id {
Subroutine es_build_id: not called CC=2 SCAR=17.9
Pod undocumented
59  
60 0 my $self = shift;
61 0 my $rs = shift;
62  
63 0 my $pks = $rs->es_id_columns;
64  
65 0 my $ids = [];
66  
67 0 for my $pk (@$pks) {
68  
69 0 push @$ids, $self->$pk;
70 }
71  
72 0 return join '_', @$ids;
73 }
74  
75  
76  
77 0 ▶around 'insert' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
78 0 my $orig = shift;
79 0 my $self = shift;
80  
81 0 warn "Inserting ...\n";
82 0 $self->es_index;
83 1 };
84  
85 0 ▶sub es_index_transfer {
Subroutine es_index_transfer: not called CC=2 SCAR=17.9
Pod undocumented
86  
87 0 my ( $self, $body ) = @_;
88  
89 0 my $type = $self->result_source->name;
90  
91 0 my $parent = {};
92 0 ▶ if ( $self->es_is_child ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->es_is_child) 0 0 0
93  
94 0 $parent = { parent => $self->es_parent };
95 }
96  
97 }
98  
99 0 ▶sub es {
Subroutine es: not called CC=1 SCAR=6.9
Pod undocumented
100  
101 0 return shift->schema->es;
102 }
103  
104 0 ▶sub schema {
Subroutine schema: not called CC=1 SCAR=6.9
Pod undocumented
105  
106 0 return shift->result_source->schema;
107 }
108  
109 1 1;
« ElasticSync/Role/ElasticSchema.pm ↑ Summary ElasticSync.pm »