| 1 | package CPAN::Testers::API::Controller::Report; | ||||||||||
| 2 | 1 | our $VERSION = '0.025'; | |||||||||
| 3 | # ABSTRACT: Work with raw test reports | ||||||||||
| 4 | |||||||||||
| 5 | #pod =head1 DESCRIPTION | ||||||||||
| 6 | #pod | ||||||||||
| 7 | #pod This API allows working directly with the JSON report documents | ||||||||||
| 8 | #pod submitted by the army of testers of CPAN. | ||||||||||
| 9 | #pod | ||||||||||
| 10 | #pod =head1 SEE ALSO | ||||||||||
| 11 | #pod | ||||||||||
| 12 | #pod L<CPAN::Testers::Schema::Result::TestReport>, L<Mojolicious::Controller> | ||||||||||
| 13 | #pod | ||||||||||
| 14 | #pod =cut | ||||||||||
| 15 | |||||||||||
| 16 | 1 | ▶ | use Mojo::Base 'Mojolicious::Controller'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | 1 | ▶ | use CPAN::Testers::API::Base; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | |||||||||||
| 19 | #pod =method report_post | ||||||||||
| 20 | #pod | ||||||||||
| 21 | #pod ### Requests: | ||||||||||
| 22 | #pod POST /v3/report | ||||||||||
| 23 | #pod { ... } | ||||||||||
| 24 | #pod | ||||||||||
| 25 | #pod ### Response: | ||||||||||
| 26 | #pod 201 Created | ||||||||||
| 27 | #pod { "id": "..." } | ||||||||||
| 28 | #pod | ||||||||||
| 29 | #pod Submit a new CPAN Testers report. This is used by testers when they're | ||||||||||
| 30 | #pod finished running a test. | ||||||||||
| 31 | #pod | ||||||||||
| 32 | #pod =cut | ||||||||||
| 33 | |||||||||||
| 34 | ▶ | sub report_post( $c ) { | |||||||||
|
Subroutine
report_post: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 35 | 0 | $c->app->log->debug( 'Submitting Report: ' . $c->req->body ); | |||||||||
| 36 | 0 | ▶ | $c->openapi->valid_input or return; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | 0 | my $report = $c->validation->param( 'report' ); | |||||||||
| 38 | 0 | my $row = $c->schema->resultset( 'TestReport' )->create( { | |||||||||
| 39 | report => $report, | ||||||||||
| 40 | } ); | ||||||||||
| 41 | 0 | return $c->render( | |||||||||
| 42 | status => 201, | ||||||||||
| 43 | openapi => { | ||||||||||
| 44 | id => $row->id, | ||||||||||
| 45 | }, | ||||||||||
| 46 | ); | ||||||||||
| 47 | } | ||||||||||
| 48 | |||||||||||
| 49 | #pod =method report_get | ||||||||||
| 50 | #pod | ||||||||||
| 51 | #pod ### Requests: | ||||||||||
| 52 | #pod GET /v3/report/:guid | ||||||||||
| 53 | #pod | ||||||||||
| 54 | #pod ### Response | ||||||||||
| 55 | #pod 200 OK | ||||||||||
| 56 | #pod { "id": "...", ... } | ||||||||||
| 57 | #pod | ||||||||||
| 58 | #pod Get a single CPAN Testers report from the database. | ||||||||||
| 59 | #pod | ||||||||||
| 60 | #pod =cut | ||||||||||
| 61 | |||||||||||
| 62 | ▶ | sub report_get( $c ) { | |||||||||
|
Subroutine
report_get: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 63 | 0 | ▶ | $c->openapi->valid_input or return; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 64 | 0 | my $id = $c->validation->param( 'id' ); | |||||||||
| 65 | 0 | my $row = $c->schema->resultset( 'TestReport' )->find( $id ); | |||||||||
| 66 | 0 | ▶ | if ( !$row ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 67 | 0 | return $c->render( | |||||||||
| 68 | status => 404, | ||||||||||
| 69 | openapi => { | ||||||||||
| 70 | errors => [ | ||||||||||
| 71 | { | ||||||||||
| 72 | message => 'Report ID not found', | ||||||||||
| 73 | path => '/id', | ||||||||||
| 74 | }, | ||||||||||
| 75 | ], | ||||||||||
| 76 | }, | ||||||||||
| 77 | ); | ||||||||||
| 78 | } | ||||||||||
| 79 | 0 | return $c->render( | |||||||||
| 80 | openapi => $row->report, | ||||||||||
| 81 | ); | ||||||||||
| 82 | } | ||||||||||
| 83 | |||||||||||
| 84 | 1 | 1; | |||||||||
| 85 | |||||||||||
| 86 | __END__ | ||||||||||
| 87 | |||||||||||
| 88 | =pod | ||||||||||
| 89 | |||||||||||
| 90 | =head1 NAME | ||||||||||
| 91 | |||||||||||
| 92 | CPAN::Testers::API::Controller::Report - Work with raw test reports | ||||||||||
| 93 | |||||||||||
| 94 | =head1 VERSION | ||||||||||
| 95 | |||||||||||
| 96 | version 0.025 | ||||||||||
| 97 | |||||||||||
| 98 | =head1 DESCRIPTION | ||||||||||
| 99 | |||||||||||
| 100 | This API allows working directly with the JSON report documents | ||||||||||
| 101 | submitted by the army of testers of CPAN. | ||||||||||
| 102 | |||||||||||
| 103 | =head1 METHODS | ||||||||||
| 104 | |||||||||||
| 105 | =head2 report_post | ||||||||||
| 106 | |||||||||||
| 107 | ### Requests: | ||||||||||
| 108 | POST /v3/report | ||||||||||
| 109 | { ... } | ||||||||||
| 110 | |||||||||||
| 111 | ### Response: | ||||||||||
| 112 | 201 Created | ||||||||||
| 113 | { "id": "..." } | ||||||||||
| 114 | |||||||||||
| 115 | Submit a new CPAN Testers report. This is used by testers when they're | ||||||||||
| 116 | finished running a test. | ||||||||||
| 117 | |||||||||||
| 118 | =head2 report_get | ||||||||||
| 119 | |||||||||||
| 120 | ### Requests: | ||||||||||
| 121 | GET /v3/report/:guid | ||||||||||
| 122 | |||||||||||
| 123 | ### Response | ||||||||||
| 124 | 200 OK | ||||||||||
| 125 | { "id": "...", ... } | ||||||||||
| 126 | |||||||||||
| 127 | Get a single CPAN Testers report from the database. | ||||||||||
| 128 | |||||||||||
| 129 | =head1 SEE ALSO | ||||||||||
| 130 | |||||||||||
| 131 | L<CPAN::Testers::Schema::Result::TestReport>, L<Mojolicious::Controller> | ||||||||||
| 132 | |||||||||||
| 133 | =head1 AUTHOR | ||||||||||
| 134 | |||||||||||
| 135 | Doug Bell <preaction@cpan.org> | ||||||||||
| 136 | |||||||||||
| 137 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 138 | |||||||||||
| 139 | This software is copyright (c) 2018 by Doug Bell. | ||||||||||
| 140 | |||||||||||
| 141 | This is free software; you can redistribute it and/or modify it under | ||||||||||
| 142 | the same terms as the Perl 5 programming language system itself. | ||||||||||
| 143 | |||||||||||
| 144 | =cut | ||||||||||