File Coverage

blib/lib/Mojo/InfluxDB/Result.pm
Criterion Covered Total %
statement 9 14 64.2
branch n/a
condition n/a
subroutine 3 5 60.0
pod 1 1 100.0
total 13 20 65.0


line stmt bran cond sub pod time code
1             package Mojo::InfluxDB::Result;
2             # ABSTRACT: Result container for queries
3             $Mojo::InfluxDB::Result::VERSION = '0.1';
4 1     1   8 use Mojo::Base -base, -signatures;
  1         2  
  1         9  
5 1     1   255 use Mojo::Collection qw/ c /;
  1         2  
  1         65  
6 1     1   472 use Mojo::InfluxDB::Row;
  1         4  
  1         9  
7              
8             has src => sub { die "This result is empty" };
9             has 'time_zone';
10              
11             for my $field (qw/ series messages error statement_id /) {
12             has $field => sub($self){ $self->src->{$field} };
13             }
14              
15             has series => sub($self) {
16             c( $self->src->{series}->@* )->map(sub{
17             Mojo::InfluxDB::Row->new(
18             src => $_,
19             time_zone => $self->time_zone
20             )
21             })
22             };
23              
24 0     0 1   sub points ( $self ) {
  0            
  0            
25 0     0     $self->series->map(sub{ $_->points })->flatten;
  0            
26             }
27              
28             1;
29              
30             __END__
31              
32             =pod
33              
34             =encoding UTF-8
35              
36             =head1 NAME
37              
38             Mojo::InfluxDB::Result - Result container for queries
39              
40             =head1 VERSION
41              
42             version 0.1
43              
44             =head1 DESCRIPTION
45              
46             You will get this objects form L<InfluxDB> query methods. This is a container of query results.
47              
48             =head1 ATTRIBUTES
49              
50             =head2 src
51              
52             this is where L<InfluxDB::Result> will store the raw data retrieved for this row. Most attributes of this class will read from here.
53              
54             =head2 time_zone
55              
56             an optional time_zone that will be passed into every L<Mojo::InfluxDB::Point> returned by points().
57              
58             =head2 names
59              
60             =head2 tags
61              
62             =head2 columns
63              
64             =head2 values
65              
66             =head2 partial
67              
68             =head2 points
69              
70             A L<Mojo::Collection> of L<Mojo::InfluxDB::Point>.
71              
72             =head1 AUTHOR
73              
74             Gonzalo Radio <gonzalo@gnzl.net>
75              
76             =head1 COPYRIGHT AND LICENSE
77              
78             This software is copyright (c) 2020 by Gonzalo Radio.
79              
80             This is free software; you can redistribute it and/or modify it under
81             the same terms as the Perl 5 programming language system itself.
82              
83             =cut