Filename | /home/vagrant/kohaclone/circ/ysearch.pl |
Statements | Executed 0 statements in 0s |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 96µs | 1.62ms | CORE:binmode (opcode) | CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::
1 | 1 | 1 | 73µs | 413µs | BEGIN@27 | CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::
1 | 1 | 1 | 61µs | 193µs | BEGIN@28 | CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::
1 | 1 | 1 | 61µs | 146µs | BEGIN@32 | CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::
1 | 1 | 1 | 47µs | 405µs | BEGIN@34 | CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::
1 | 1 | 1 | 28µs | 115µs | BEGIN@30 | CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::
1 | 1 | 1 | 25µs | 25µs | CORE:open (opcode) | CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::
1 | 1 | 1 | 20µs | 20µs | BEGIN@31 | CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::
1 | 1 | 1 | 20µs | 28µs | BEGIN@29 | CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::
2 | 2 | 1 | 14µs | 14µs | CORE:print (opcode) | CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::
1 | 1 | 1 | 5µs | 5µs | CORE:pack (opcode) | CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::
1 | 1 | 1 | 2µs | 2µs | CORE:unpack (opcode) | CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::
0 | 0 | 0 | 0s | 0s | __ANON__[:115] | CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | #!/usr/bin/perl | ||||
2 | 1 | 59µs | # spent 59µs making 1 call to DBIx::Class::Storage::DBI::Cursor::DESTROY | ||
3 | # This software is placed under the gnu General Public License, v2 (http://www.gnu.org/licenses/gpl.html) | ||||
4 | |||||
5 | # Copyright 2007 Tamil s.a.r.l. | ||||
6 | # Parts copyright 2010-2012 Athens County Public Libraries | ||||
7 | # | ||||
8 | # This file is part of Koha. | ||||
9 | # | ||||
10 | # Koha is free software; you can redistribute it and/or modify it | ||||
11 | # under the terms of the GNU General Public License as published by | ||||
12 | # the Free Software Foundation; either version 3 of the License, or | ||||
13 | # (at your option) any later version. | ||||
14 | # | ||||
15 | # Koha is distributed in the hope that it will be useful, but | ||||
16 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
18 | # GNU General Public License for more details. | ||||
19 | # | ||||
20 | # You should have received a copy of the GNU General Public License | ||||
21 | # along with Koha; if not, see <http://www.gnu.org/licenses>. | ||||
22 | |||||
23 | =head1 ysearch.pl | ||||
24 | |||||
25 | =cut | ||||
26 | |||||
27 | 2 | 753µs | # spent 413µs (73+340) within CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::BEGIN@27 which was called:
# once (73µs+340µs) by CGI::Compile::_eval at line 27 # spent 413µs making 1 call to CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::BEGIN@27
# spent 340µs making 1 call to Modern::Perl::import | ||
28 | 2 | 326µs | # spent 193µs (61+132) within CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::BEGIN@28 which was called:
# once (61µs+132µs) by CGI::Compile::_eval at line 28 # spent 193µs making 1 call to CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::BEGIN@28
# spent 132µs making 1 call to CGI::import | ||
29 | 2 | 35µs | # spent 28µs (20+8) within CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::BEGIN@29 which was called:
# once (20µs+8µs) by CGI::Compile::_eval at line 29 # spent 28µs making 1 call to CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::BEGIN@29
# spent 8µs making 1 call to C4::Context::import | ||
30 | 2 | 202µs | # spent 115µs (28+87) within CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::BEGIN@30 which was called:
# once (28µs+87µs) by CGI::Compile::_eval at line 30 # spent 115µs making 1 call to CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::BEGIN@30
# spent 87µs making 1 call to Exporter::import | ||
31 | 1 | 20µs | # spent 20µs within CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::BEGIN@31 which was called:
# once (20µs+0s) by CGI::Compile::_eval at line 31 # spent 20µs making 1 call to CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::BEGIN@31 | ||
32 | 2 | 232µs | # spent 146µs (61+86) within CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::BEGIN@32 which was called:
# once (61µs+86µs) by CGI::Compile::_eval at line 32 # spent 146µs making 1 call to CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::BEGIN@32
# spent 86µs making 1 call to Exporter::import | ||
33 | |||||
34 | 2 | 764µs | # spent 405µs (47+358) within CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::BEGIN@34 which was called:
# once (47µs+358µs) by CGI::Compile::_eval at line 34 # spent 405µs making 1 call to CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::BEGIN@34
# spent 358µs making 1 call to JSON::import | ||
35 | |||||
36 | 1 | 238µs | my $input = new CGI; # spent 238µs making 1 call to Plack::Sandbox::_2fetc_2fkoha_2fsites_2fkohadev_2fplack_2epsgi::__ANON__ | ||
37 | 1 | 75µs | my $query = $input->param('term'); # spent 75µs making 1 call to CGI::param | ||
38 | |||||
39 | 5 | 3.13ms | binmode STDOUT, ":encoding(UTF-8)"; # spent 1.62ms making 1 call to CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::CORE:binmode
# spent 1.47ms making 1 call to PerlIO::import
# spent 20µs making 1 call to Encode::find_encoding
# spent 15µs making 1 call to Encode::Encoding::renew
# spent 1µs making 1 call to Encode::Encoding::needs_lines | ||
40 | 2 | 190µs | print $input->header( -type => 'text/plain', -charset => 'UTF-8' ); # spent 181µs making 1 call to CGI::header
# spent 8µs making 1 call to CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::CORE:print | ||
41 | |||||
42 | 4 | 21.0ms | my ( $auth_status, $sessionID ) = check_cookie_auth( $input->cookie('CGISESSID'), { circulate => '*' } ); # spent 18.8ms making 1 call to C4::Auth::check_cookie_auth
# spent 1.68ms making 1 call to CGI::Session::DESTROY
# spent 458µs making 1 call to CGI::cookie
# spent 56µs making 1 call to CGI::Session::Driver::DBI::DESTROY | ||
43 | if ( $auth_status ne "ok" ) { | ||||
44 | exit 0; | ||||
45 | } | ||||
46 | |||||
47 | my $limit_on_branch; | ||||
48 | 1 | 2.89ms | if ( C4::Context->preference("IndependentBranches") # spent 2.89ms making 1 call to C4::Context::preference | ||
49 | && C4::Context->userenv | ||||
50 | && !C4::Context->IsSuperLibrarian() | ||||
51 | && C4::Context->userenv->{'branch'} ) { | ||||
52 | $limit_on_branch = 1; | ||||
53 | } | ||||
54 | |||||
55 | my @parts = split( / /, $query ); | ||||
56 | my @params; | ||||
57 | foreach my $p (@parts) { | ||||
58 | push( | ||||
59 | @params, | ||||
60 | -or => [ | ||||
61 | surname => { -like => "%$p%" }, | ||||
62 | firstname => { -like => "%$p%" }, | ||||
63 | cardnumber => { -like => "$p%" }, | ||||
64 | ] | ||||
65 | ); | ||||
66 | } | ||||
67 | |||||
68 | push( @params, { branchcode => C4::Context->userenv->{branch} } ) if $limit_on_branch; | ||||
69 | |||||
70 | 1 | 462µs | my $borrowers_rs = Koha::Borrowers->search( # spent 462µs making 1 call to Koha::Objects::search | ||
71 | { -and => \@params }, | ||||
72 | { | ||||
73 | # Get the first 10 results | ||||
74 | page => 1, | ||||
75 | rows => 10, | ||||
76 | order_by => [ 'surname', 'firstname' ], | ||||
77 | }, | ||||
78 | ); | ||||
79 | |||||
80 | my @borrowers; | ||||
81 | 1 | 37.6ms | while ( my $b = $borrowers_rs->next ) { # spent 37.6ms making 1 call to Koha::Objects::next | ||
82 | push @borrowers, | ||||
83 | { borrowernumber => $b->borrowernumber, | ||||
84 | surname => $b->surname // '', | ||||
85 | firstname => $b->firstname // '', | ||||
86 | cardnumber => $b->cardnumber // '', | ||||
87 | dateofbirth => format_sqldatetime($b->dateofbirth, undef, undef, 1) // '', | ||||
88 | address => $b->address // '', | ||||
89 | city => $b->city // '', | ||||
90 | zipcode => $b->zipcode // '', | ||||
91 | country => $b->country // '', | ||||
92 | }; | ||||
93 | } | ||||
94 | |||||
95 | 3 | 86µs | print to_json( \@borrowers ); # spent 79µs making 1 call to JSON::to_json
# spent 6µs making 1 call to CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::CORE:print
# spent 1µs making 1 call to JSON::XS::DESTROY | ||
96 | |||||
97 | }; | ||||
98 | my $self = shift; | ||||
99 | 2 | 7µs | my $exit_val = unpack('C', pack('C', sprintf('%.0f', $rv))); # spent 5µs making 1 call to CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::CORE:pack
# spent 2µs making 1 call to CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::CORE:unpack | ||
100 | if ($@) { | ||||
101 | die $@ unless ( | ||||
102 | ref($@) eq 'ARRAY' and | ||||
103 | $@->[0] eq "EXIT\n" | ||||
104 | ); | ||||
105 | my $exit_param = unpack('C', pack('C', sprintf('%.0f', $@->[1]))); | ||||
106 | |||||
107 | if ($exit_param != 0 && !$CGI::Compile::RETURN_EXIT_VAL && !$self->{return_exit_val}) { | ||||
108 | die "exited nonzero: $exit_param"; | ||||
109 | } | ||||
110 | |||||
111 | $exit_val = $exit_param; | ||||
112 | } | ||||
113 | |||||
114 | return $exit_val; | ||||
115 | }; | ||||
# spent 1.62ms (96µs+1.53) within CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::CORE:binmode which was called:
# once (96µs+1.53ms) by CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::__ANON__[/home/vagrant/kohaclone/circ/ysearch.pl:115] at line 39 | |||||
# spent 25µs within CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::CORE:open which was called:
# once (25µs+0s) by CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::__ANON__[/home/vagrant/kohaclone/circ/ysearch.pl:115] at line 2 of (eval 1176)[CGI/Compile.pm:12] | |||||
# spent 5µs within CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::CORE:pack which was called:
# once (5µs+0s) by CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::__ANON__[/home/vagrant/kohaclone/circ/ysearch.pl:115] at line 99 | |||||
# spent 14µs within CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::CORE:print which was called 2 times, avg 7µs/call:
# once (8µs+0s) by CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::__ANON__[/home/vagrant/kohaclone/circ/ysearch.pl:115] at line 40
# once (6µs+0s) by CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::__ANON__[/home/vagrant/kohaclone/circ/ysearch.pl:115] at line 95 | |||||
# spent 2µs within CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::CORE:unpack which was called:
# once (2µs+0s) by CGI::Compile::ROOT::home_vagrant_kohaclone_circ_ysearch_2epl::__ANON__[/home/vagrant/kohaclone/circ/ysearch.pl:115] at line 99 |