Controller/ToolsProjects.pm untested

filter: Statementstmt 0.0% 0 / 29 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 36 CC 1 SCAR 6.9
CC
1
Cov
0%
load_projects
2.0
save_projects
2.0
BEGIN
2.0
CRAP 2.0
1 package Daje::Controller::ToolsProjects;
2 use Mojo::Base 'Mojolicious::Controller', -signatures;
3 use v5.40;
4  
5 # NAME
6 # ====
7 #
8 # Daje::Controller::Tools - Mojolicious Plugin
9 #
10 # SYNOPSIS
11 # ========
12 #
13 #
14 #
15 # DESCRIPTION
16 # ===========
17 #
18 # Daje::Controller::Tools is a Mojolicious plugin.
19 #
20 # METHODS
21 # =======
22 #
23 # Register plugin in L<Mojolicious> application.
24 #
25 # LICENSE
26 # =======
27 #
28 # Copyright (C) janeskil1525.
29 #
30 # This library is free software; you can redistribute it and/or modify
31 # it under the same terms as Perl itself.
32 #
33 # AUTHOR
34 # ======
35 #
36 # janeskil1525 E<lt>janeskil1525@gmail.com
37 #
38  
39 use Data::Dumper;
40  
41 sub load_projects ($self) {
42  
43 $self->app->log->debug('Daje::Controller::Toolsprojects::load_projects');
44 $self->render_later;
45 # my ($companies_pkey, $users_pkey) = $self->jwt->companies_users_pkey(
46 # $self->req->headers->header('X-Token-Check')
47 # );
48  
49 $self->app->log->debug($self->req->headers->header('X-Token-Check'));
50 # my $setting = $self->param('setting');
51 $self->v_tools_projects->load_full_list_p()->then(sub($result) {
52 $self->render(json => $result->{data});
53 })->catch(sub($err) {
54 $self->app->log->error('Daje::Controller::Toolsprojects::load_projects ' . $err);
55 $self->render(json => { 'result' => 0, data => $err });
56 })->wait;
57 }
58  
59 sub save_projects ($self) {
60  
61 $self->app->log->debug('Daje::Controller::Toolsprojects::save_projects');
62 $self->render_later;
63  
64 my $json_hash = decode_json ($self->req->body);
65 $self->tools_projects->insert_tools_projects_p($json_hash)->then(sub ($result) {
66 $self->render(json => {'result' => $result});
67 })->catch( sub ($err) {
68 $self->render(json => {'result' => $err});
69 })->wait;
70 }
71  
72  
73 1;
74  
75 #################### pod generated by Pod::Autopod - keep this line to make pod updates possible ####################
76  
77 =head1 NAME
78  
79  
80 Daje::Controller::Tools - Mojolicious Plugin
81  
82  
83  
84 =head1 SYNOPSIS
85  
86  
87  
88  
89  
90  
91 =head1 DESCRIPTION
92  
93  
94 Daje::Controller::Tools is a Mojolicious plugin.
95  
96  
97  
98 =head1 REQUIRES
99  
100 L<Data::Dumper>
101  
102 L<v5.40>
103  
104 L<Mojo::Base>
105  
106  
107 =head1 METHODS
108  
109  
110 Register plugin in L<Mojolicious> application.
111  
112  
113  
114 =head1 AUTHOR
115  
116  
117 janeskil1525 E<lt>janeskil1525@gmail.com
118  
119  
120  
121 =head1 LICENSE
122  
123  
124 Copyright (C) janeskil1525.
125  
126 This library is free software; you can redistribute it and/or modify
127 it under the same terms as Perl itself.
128  
129  
130  
131 =cut
132