line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBIx::Class::QueryLog::Transaction; |
2
|
|
|
|
|
|
|
$DBIx::Class::QueryLog::Transaction::VERSION = '1.005001'; |
3
|
|
|
|
|
|
|
# ABSTRACT: A Transaction |
4
|
|
|
|
|
|
|
|
5
|
5
|
|
|
5
|
|
29
|
use Moo; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
27
|
|
6
|
5
|
|
|
5
|
|
1271
|
use Types::Standard qw( Bool ArrayRef ); |
|
5
|
|
|
|
|
17
|
|
|
5
|
|
|
|
|
32
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
extends 'DBIx::Class::QueryLog::Query'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has committed => ( |
11
|
|
|
|
|
|
|
is => 'rw', |
12
|
|
|
|
|
|
|
isa => Bool |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has queries => ( |
16
|
|
|
|
|
|
|
traits => [qw(Array)], |
17
|
|
|
|
|
|
|
is => 'rw', |
18
|
|
|
|
|
|
|
isa => ArrayRef, |
19
|
|
|
|
|
|
|
default => sub { [] }, |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
7
|
|
|
7
|
1
|
38
|
sub add_to_queries { push @{shift->queries}, @_ } |
|
7
|
|
|
|
|
96
|
|
23
|
1
|
|
|
1
|
1
|
34
|
sub count { scalar @{shift->queries} } |
|
1
|
|
|
|
|
13
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has rolledback => ( |
26
|
|
|
|
|
|
|
is => 'rw', |
27
|
|
|
|
|
|
|
isa => Bool |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub time_elapsed { |
31
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
0
|
my $total = 0; |
34
|
0
|
|
|
|
|
0
|
foreach my $q (@{ $self->queries }) { |
|
0
|
|
|
|
|
0
|
|
35
|
0
|
|
|
|
|
0
|
$total += $q->time_elapsed; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
0
|
return $total; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub get_sorted_queries { |
42
|
4
|
|
|
4
|
1
|
10
|
my ($self, $sql) = @_; |
43
|
|
|
|
|
|
|
|
44
|
4
|
|
|
|
|
6
|
my @qs; |
45
|
4
|
100
|
|
|
|
8
|
if($sql) { |
46
|
3
|
|
|
|
|
5
|
@qs = grep({ $_->sql eq $sql } @{ $self->queries }); |
|
3
|
|
|
|
|
46
|
|
|
3
|
|
|
|
|
38
|
|
47
|
|
|
|
|
|
|
} else { |
48
|
1
|
|
|
|
|
2
|
@qs = @{ $self->queries }; |
|
1
|
|
|
|
|
15
|
|
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
4
|
|
|
|
|
73
|
return [ reverse sort { $a->time_elapsed <=> $b->time_elapsed } @qs ]; |
|
1
|
|
|
|
|
4
|
|
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
__END__ |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=pod |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=encoding UTF-8 |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 NAME |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
DBIx::Class::QueryLog::Transaction - A Transaction |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 VERSION |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
version 1.005001 |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 SYNOPSIS |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Represents a transaction. All queries executed with the context of this |
73
|
|
|
|
|
|
|
transaction are stored herein, as well as a start time, end time and flag |
74
|
|
|
|
|
|
|
for committed or rolledback. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 METHODS |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 new |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Create a new DBIx::Class::QueryLog::Transcation |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 bucket |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
The bucket this tranaction is in. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 queries |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Arrayref containing all queries executed, in order of execution. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 committed |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Flag indicating if this transaction was committed. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 rolledback |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Flag indicating if this transaction was rolled back. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head2 start_time |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Time this transaction started. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head2 end_time |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Time this transaction ended. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 time_elapsed |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Time this transaction took to execute. start - end. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head2 add_to_queries |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Add the provided query to this transactions list. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 count |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Returns the number of queries in this Transaction |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head2 get_sorted_queries([ $sql ]) |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Returns all the queries in this Transaction, sorted by elapsed time. |
121
|
|
|
|
|
|
|
(descending). |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
If given an argument of an SQL statement, only queries matching that statement |
124
|
|
|
|
|
|
|
will be considered. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 AUTHORS |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=over 4 |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=item * |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com> |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=item * |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Cory G Watson <gphat at cpan.org> |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=back |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
This software is copyright (c) 2015 by Cory G Watson <gphat at cpan.org>. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
145
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=cut |