| 1 | package DBIx::Class::QueryLog::Query; | ||||||||||
| 2 | 6 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | |||||||||||
| 4 | 6 | has bucket => ( | |||||||||
| 5 | is => 'rw', | ||||||||||
| 6 | isa => 'Str' | ||||||||||
| 7 | ); | ||||||||||
| 8 | |||||||||||
| 9 | 6 | has end_time => ( | |||||||||
| 10 | is => 'rw', | ||||||||||
| 11 | isa => 'Num' | ||||||||||
| 12 | ); | ||||||||||
| 13 | |||||||||||
| 14 | 6 | has params => ( | |||||||||
| 15 | is => 'rw', | ||||||||||
| 16 | isa => 'ArrayRef' | ||||||||||
| 17 | ); | ||||||||||
| 18 | |||||||||||
| 19 | 6 | has sql => ( | |||||||||
| 20 | is => 'rw', | ||||||||||
| 21 | isa => 'Str' | ||||||||||
| 22 | ); | ||||||||||
| 23 | |||||||||||
| 24 | 6 | has start_time => ( | |||||||||
| 25 | is => 'rw', | ||||||||||
| 26 | isa => 'Num' | ||||||||||
| 27 | ); | ||||||||||
| 28 | |||||||||||
| 29 | =head1 NAME | ||||||||||
| 30 | |||||||||||
| 31 | DBIx::Class::QueryLog::Query - A Query | ||||||||||
| 32 | |||||||||||
| 33 | =head1 SYNOPSIS | ||||||||||
| 34 | |||||||||||
| 35 | Represents a query. The sql, parameters, start time and end time are stored. | ||||||||||
| 36 | |||||||||||
| 37 | =head1 METHODS | ||||||||||
| 38 | |||||||||||
| 39 | =head2 bucket | ||||||||||
| 40 | |||||||||||
| 41 | The bucket this query is in. | ||||||||||
| 42 | |||||||||||
| 43 | =head2 start_time | ||||||||||
| 44 | |||||||||||
| 45 | Time this query started. | ||||||||||
| 46 | |||||||||||
| 47 | =head2 end_time | ||||||||||
| 48 | |||||||||||
| 49 | Time this query ended. | ||||||||||
| 50 | |||||||||||
| 51 | =head2 sql | ||||||||||
| 52 | |||||||||||
| 53 | SQL for this query. | ||||||||||
| 54 | |||||||||||
| 55 | =head2 params | ||||||||||
| 56 | |||||||||||
| 57 | Parameters used with this query. | ||||||||||
| 58 | |||||||||||
| 59 | =head2 time_elapsed | ||||||||||
| 60 | |||||||||||
| 61 | Time this query took to execute. start - end. | ||||||||||
| 62 | |||||||||||
| 63 | =cut | ||||||||||
| 64 | |||||||||||
| 65 | sub time_elapsed { | ||||||||||
| 66 | 26 | ▶ | my $self = shift; | ||||||||
|
Subroutine
time_elapsed: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 67 | |||||||||||
| 68 | 26 | return $self->end_time - $self->start_time; | |||||||||
| 69 | } | ||||||||||
| 70 | |||||||||||
| 71 | =head2 count | ||||||||||
| 72 | |||||||||||
| 73 | Returns 1. Exists to make it easier for QueryLog to get a count of | ||||||||||
| 74 | queries executed. | ||||||||||
| 75 | |||||||||||
| 76 | =cut | ||||||||||
| 77 | sub count { | ||||||||||
| 78 | |||||||||||
| 79 | 0 | ▶ | return 1; | ||||||||
|
Subroutine
count: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 80 | } | ||||||||||
| 81 | |||||||||||
| 82 | =head2 queries | ||||||||||
| 83 | |||||||||||
| 84 | Returns this query, here to make QueryLog's job easier. | ||||||||||
| 85 | |||||||||||
| 86 | =cut | ||||||||||
| 87 | sub queries { | ||||||||||
| 88 | 3 | ▶ | my $self = shift; | ||||||||
|
Subroutine
queries: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 89 | |||||||||||
| 90 | 3 | return [ $self ]; | |||||||||
| 91 | } | ||||||||||
| 92 | |||||||||||
| 93 | =head2 get_sorted_queries | ||||||||||
| 94 | |||||||||||
| 95 | Returns this query. Here to make QueryLog's job easier. | ||||||||||
| 96 | |||||||||||
| 97 | =cut | ||||||||||
| 98 | sub get_sorted_queries { | ||||||||||
| 99 | 10 | ▶ | my ($self, $sql) = @_; | ||||||||
|
Subroutine
get_sorted_queries: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 100 | |||||||||||
| 101 | 10 | ▶ | if(defined($sql)) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 102 | 9 | ▶ | if($self->sql eq $sql) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 103 | 5 | return [ $self ]; | |||||||||
| 104 | } else { | ||||||||||
| 105 | 4 | return [ ]; | |||||||||
| 106 | } | ||||||||||
| 107 | } | ||||||||||
| 108 | |||||||||||
| 109 | 1 | return [ $self ]; | |||||||||
| 110 | } | ||||||||||
| 111 | |||||||||||
| 112 | =head1 AUTHOR | ||||||||||
| 113 | |||||||||||
| 114 | Cory G Watson, C<< <gphat at cpan.org> >> | ||||||||||
| 115 | |||||||||||
| 116 | =head1 ACKNOWLEDGEMENTS | ||||||||||
| 117 | |||||||||||
| 118 | =head1 COPYRIGHT & LICENSE | ||||||||||
| 119 | |||||||||||
| 120 | Copyright 2009 Cory G Watson, all rights reserved. | ||||||||||
| 121 | |||||||||||
| 122 | This program is free software; you can redistribute it and/or modify it | ||||||||||
| 123 | under the same terms as Perl itself. | ||||||||||
| 124 | |||||||||||
| 125 | =cut | ||||||||||
| 126 | |||||||||||
| 127 | 6 | __PACKAGE__->meta->make_immutable; | |||||||||
| 128 | |||||||||||
| 129 | 6 | 1; | |||||||||