Profile of lib/PONAPI/DAO/Request/Role/UpdateLike.pm

← Index
NYTProf Performance Profile «line view»
For script/ponapi
Run on Wed Feb 10 15:51:26 2016
Reported on Thu Feb 11 09:43:11 2016

Filename | /home/mickey/git_tree/PONAPI/Server/lib/PONAPI/DAO/Request/Role/UpdateLike.pm
Statements | Executed 13 statements in 612µs

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
1 | 1 | 1 | 802µs | 26.1ms | PONAPI::DAO::Request::Role::UpdateLike::::BEGIN@7PONAPI::DAO::Request::Role::UpdateLike::BEGIN@7
1 | 1 | 1 | 234µs | 455µs | PONAPI::DAO::Request::Role::UpdateLike::::BEGIN@6PONAPI::DAO::Request::Role::UpdateLike::BEGIN@6
1 | 1 | 1 | 18µs | 2.34ms | PONAPI::DAO::Request::Role::UpdateLike::::BEGIN@4PONAPI::DAO::Request::Role::UpdateLike::BEGIN@4
1 | 1 | 1 | 18µs | 115µs | PONAPI::DAO::Request::Role::UpdateLike::::BEGIN@80PONAPI::DAO::Request::Role::UpdateLike::BEGIN@80
1 | 1 | 1 | 11µs | 11µs | PONAPI::DAO::Request::Role::UpdateLike::::BEGIN@79PONAPI::DAO::Request::Role::UpdateLike::BEGIN@79
0 | 0 | 0 | 0s | 0s | PONAPI::DAO::Request::Role::UpdateLike::::__ANON__[lib/PONAPI/DAO/Request/Role/UpdateLike.pm:21]PONAPI::DAO::Request::Role::UpdateLike::__ANON__[lib/PONAPI/DAO/Request/Role/UpdateLike.pm:21]
0 | 0 | 0 | 0s | 0s | PONAPI::DAO::Request::Role::UpdateLike::::_add_success_metaPONAPI::DAO::Request::Role::UpdateLike::_add_success_meta
0 | 0 | 0 | 0s | 0s | PONAPI::DAO::Request::Role::UpdateLike::::_get_resource_for_metaPONAPI::DAO::Request::Role::UpdateLike::_get_resource_for_meta
0 | 0 | 0 | 0s | 0s | PONAPI::DAO::Request::Role::UpdateLike::::_verify_update_responsePONAPI::DAO::Request::Role::UpdateLike::_verify_update_response

Call graph for these subroutines as a Graphviz dot language file.

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 |  |  |  |  | # ABSTRACT: DAO request role - `update` & like related functionality
2 |  |  |  |  | package PONAPI::DAO::Request::Role::UpdateLike;
3 |  |  |  |  |
4 | 2 | 48µs | 2 | 4.67ms | # spent 2.34ms (18µs+2.33) within PONAPI::DAO::Request::Role::UpdateLike::BEGIN@4 which was called: # once (18µs+2.33ms) by Module::Runtime::require_module at line 4 use Moose::Role; # spent 2.34ms making 1 call to PONAPI::DAO::Request::Role::UpdateLike::BEGIN@4 # spent 2.33ms making 1 call to Moose::Role::import
5 |  |  |  |  |
6 | 2 | 105µs | 2 | 563µs | # spent 455µs (234+222) within PONAPI::DAO::Request::Role::UpdateLike::BEGIN@6 which was called: # once (234µs+222µs) by Module::Runtime::require_module at line 6 use PONAPI::Constants; # spent 455µs making 1 call to PONAPI::DAO::Request::Role::UpdateLike::BEGIN@6 # spent 108µs making 1 call to Exporter::import
7 | 2 | 374µs | 1 | 26.1ms | # spent 26.1ms (802µs+25.3) within PONAPI::DAO::Request::Role::UpdateLike::BEGIN@7 which was called: # once (802µs+25.3ms) by Module::Runtime::require_module at line 7 use PONAPI::Exception; # spent 26.1ms making 1 call to PONAPI::DAO::Request::Role::UpdateLike::BEGIN@7
8 |  |  |  |  |
9 | 1 | 2µs | 1 | 141µs | has respond_to_updates_with_200 => ( # spent 141µs making 1 call to Moose::Role::has
10 |  |  |  |  | is => 'ro',
11 |  |  |  |  | isa => 'Bool',
12 |  |  |  |  | );
13 |  |  |  |  |
14 |  |  |  |  | has update_nothing_status => (
15 |  |  |  |  | is => 'ro',
16 |  |  |  |  | isa => 'Int',
17 |  |  |  |  | # http://jsonapi.org/format/#crud-updating-relationship-responses-204
18 |  |  |  |  | # Basically, we return a 204, UNLESS it's an ->update() call, in which
19 |  |  |  |  | # case it has to return a 404:
20 |  |  |  |  | # http://jsonapi.org/format/#crud-updating-responses-404
21 |  |  |  |  | default => sub { 204 },
22 | 1 | 3µs | 1 | 71µs | ); # spent 71µs making 1 call to Moose::Role::has
23 |  |  |  |  |
24 |  |  |  |  | sub _verify_update_response {
25 |  |  |  |  | my ( $self, $ret, @extra ) = @_;
26 |  |  |  |  |
27 |  |  |  |  | PONAPI::Exception->throw(
28 |  |  |  |  | internal => 1,
29 |  |  |  |  | message => "update-like operation returned an unexpected value"
30 |  |  |  |  | ) unless exists $PONAPI_UPDATE_RETURN_VALUES{$ret};
31 |  |  |  |  |
32 |  |  |  |  | my $doc = $self->document;
33 |  |  |  |  | return if $doc->has_errors or $doc->has_status;
34 |  |  |  |  |
35 |  |  |  |  | if ( $self->respond_to_updates_with_200 ) {
36 |  |  |  |  | $doc->set_status(200);
37 |  |  |  |  | $self->repository->retrieve(
38 |  |  |  |  | type => $self->type,
39 |  |  |  |  | id => $self->id,
40 |  |  |  |  | document => $doc,
41 |  |  |  |  | ) if $ret == PONAPI_UPDATED_EXTENDED;
42 |  |  |  |  | return 1;
43 |  |  |  |  | }
44 |  |  |  |  | else {
45 |  |  |  |  | $doc->set_status(202);
46 |  |  |  |  | }
47 |  |  |  |  |
48 |  |  |  |  | return 1;
49 |  |  |  |  | }
50 |  |  |  |  |
51 |  |  |  |  | sub _add_success_meta {
52 |  |  |  |  | my ($self, $return_status) = @_;
53 |  |  |  |  |
54 |  |  |  |  | my $resource = $self->_get_resource_for_meta;
55 |  |  |  |  |
56 |  |  |  |  | my $detail = "successfully modified $resource";
57 |  |  |  |  | if ( $return_status == PONAPI_UPDATED_NOTHING ) {
58 |  |  |  |  | my $status = $self->update_nothing_status;
59 |  |  |  |  | $self->document->set_status($status);
60 |  |  |  |  | # This should NEVER show up in a response, because it would
61 |  |  |  |  | # mean a 204 with a body; I'm still leaving it here because
62 |  |  |  |  | # a 204+body is preferable to a server error due to an empty
63 |  |  |  |  | # document.
64 |  |  |  |  | $detail = "modified nothing for $resource"
65 |  |  |  |  | }
66 |  |  |  |  |
67 |  |  |  |  | $self->document->add_meta( detail => $detail );
68 |  |  |  |  | }
69 |  |  |  |  |
70 |  |  |  |  | sub _get_resource_for_meta {
71 |  |  |  |  | my $self = shift;
72 |  |  |  |  |
73 |  |  |  |  | my $link = $self->document->req_path
74 |  |  |  |  | // ( join "/" => grep defined, '', @{$self}{qw/type id rel_type/} );
75 |  |  |  |  |
76 |  |  |  |  | return $link . " => " . $self->json->encode( $self->data );
77 |  |  |  |  | }
78 |  |  |  |  |
79 | 2 | 29µs | 1 | 11µs | # spent 11µs within PONAPI::DAO::Request::Role::UpdateLike::BEGIN@79 which was called: # once (11µs+0s) by Module::Runtime::require_module at line 79 no PONAPI::Constants; # spent 11µs making 1 call to PONAPI::DAO::Request::Role::UpdateLike::BEGIN@79
80 | 3 | 52µs | 2 | 213µs | # spent 115µs (18+97) within PONAPI::DAO::Request::Role::UpdateLike::BEGIN@80 which was called: # once (18µs+97µs) by Module::Runtime::require_module at line 80 no Moose::Role; 1; # spent 115µs making 1 call to PONAPI::DAO::Request::Role::UpdateLike::BEGIN@80 # spent 97µs making 1 call to Moose::Role::unimport
81 |  |  |  |  |
82 |  |  |  |  | __END__