Commit 5824f1c9d1bd0b9ccd659642ced6be632dcab6bc

Authored by Alex Savenko
1 parent 81164aa6

add get_report_dates() in ap + docs anchor

app/library/App/Controllers/AllPositionController.php
... ... @@ -62,9 +62,9 @@ class AllPositionController extends CrudResourceController
62 62  
63 63 $APObj = new Client(self::API_KEY);
64 64  
65   - $projects_info = $APObj->getQueries($project, $id_group);
  65 + $queries_info = $APObj->getQueries($project, $id_group);
66 66  
67   - return $projects_info;
  67 + return $queries_info;
68 68  
69 69 }
70 70  
... ... @@ -90,9 +90,9 @@ class AllPositionController extends CrudResourceController
90 90  
91 91 $APObj = new Client(self::API_KEY);
92 92  
93   - $projects_info = $APObj->getReport($project, $date, $prev_date);
  93 + $report_info = $APObj->getReport($project, $date, $prev_date);
94 94  
95   - return $projects_info;
  95 + return $report_info;
96 96  
97 97 }
98 98  
... ... @@ -106,9 +106,22 @@ class AllPositionController extends CrudResourceController
106 106  
107 107 $APObj = new Client(self::API_KEY);
108 108  
109   - $projects_info = $APObj->getVisibility($project, $get_start_date, $get_end_date, $id_se);
  109 + $visibility_info = $APObj->getVisibility($project, $get_start_date, $get_end_date, $id_se);
110 110  
111   - return $projects_info;
  111 + return $visibility_info;
  112 +
  113 + }
  114 +
  115 + public function reportDatesAction() {
  116 +
  117 + /** user params **/
  118 + $project = $this->request->get('project') ?? 418068;
  119 +
  120 + $APObj = new Client(self::API_KEY);
  121 +
  122 + $report_info = $APObj->getReportDates($project);
  123 +
  124 + return $report_info;
112 125  
113 126 }
114 127  
... ...
app/library/App/Resources/AllPositionResource.php
... ... @@ -11,7 +11,6 @@ namespace App\Resources;
11 11  
12 12 use App\Constants\AclRoles;
13 13 use App\Controllers\AllPositionController;
14   -use Phalcon\Acl;
15 14 use PhalconApi\Constants\HttpMethods;
16 15 use PhalconRest\Api\ApiEndpoint;
17 16 use PhalconRest\Api\ApiResource;
... ... @@ -24,35 +23,37 @@ class AllPositionResource extends ApiResource
24 23 $this
25 24 ->name('All Position')
26 25 ->expectsJsonData()
27   - //->transformer(ModelTransformer::class)
28 26 ->itemKey('ap')
29 27 ->collectionKey('ap')
30 28 ->deny(AclRoles::UNAUTHORIZED)
31 29 ->handler(AllPositionController::class)
32 30  
33   - ->endpoint(
34   - ApiEndpoint::factory('/project', HttpMethods::GET, 'projectAction')
35   - ->name('project')
36   - ->description('Данные о проекте')
37   - ->paramsDescription([
38   - 'required params' => [
39   - 'project' => "integer(ID проекта)"
40   - ]
41   - ])
42   - ->exampleResponse([
43   - "url" => "rukzachok.com.ua(URL проекта)",
44   - "cy" => "60(тИЦ)",
45   - "pr" => "0(Google PageRank)",
46   - "yaca" => "0(Наличие сайта в Яндекс каталоге)",
47   - "dmoz" => "0(Наличие сайта в DMOZ)",
48   - "yahoo" => "0(Наличие сайта в Yahoo)",
49   - "name" => "rukzachok.com.ua",
50   - "interval" => 0
51   - ])
52   - ->allow(AclRoles::USER)
53   - )
  31 + /** -------------------- [GET] project ------------------------------ **/
  32 + ->endpoint(
  33 + ApiEndpoint::factory('/project', HttpMethods::GET, 'projectAction')
  34 + ->name('project')
  35 + ->description('Данные о проекте')
  36 + ->paramsDescription([
  37 + 'required params' => [
  38 + 'project' => "integer(ID проекта)"
  39 + ]
  40 + ])
  41 + ->exampleResponse([
  42 + "url" => "rukzachok.com.ua(URL проекта)",
  43 + "cy" => "60(тИЦ)",
  44 + "pr" => "0(Google PageRank)",
  45 + "yaca" => "0(Наличие сайта в Яндекс каталоге)",
  46 + "dmoz" => "0(Наличие сайта в DMOZ)",
  47 + "yahoo" => "0(Наличие сайта в Yahoo)",
  48 + "name" => "rukzachok.com.ua",
  49 + "interval" => 0
  50 + ])
  51 + ->allow(AclRoles::USER)
  52 + )
  53 + /** ----------------------------------------------------------------- **/
54 54  
55   - ->endpoint(
  55 + /** -------------------- [GET] projects ----------------------------- **/
  56 + ->endpoint(
56 57 ApiEndpoint::factory('/projects', HttpMethods::GET, 'projectsAction')
57 58 ->name('projects')
58 59 ->description('Список проектов пользователя')
... ... @@ -86,8 +87,10 @@ class AllPositionResource extends ApiResource
86 87 ])
87 88 ->allow(AclRoles::USER)
88 89 )
  90 + /** ------------------------------------------------------------------**/
89 91  
90   - ->endpoint(
  92 + /** -------------------- [GET] projects_group ----------------------- **/
  93 + ->endpoint(
91 94 ApiEndpoint::factory('/projects_group', HttpMethods::GET, 'projectsGroupAction')
92 95 ->name('projects group')
93 96 ->description('Список групп проектов')
... ... @@ -106,8 +109,10 @@ class AllPositionResource extends ApiResource
106 109 ])
107 110 ->allow(AclRoles::USER)
108 111 )
  112 + /** ----------------------------------------------------------------- **/
109 113  
110   - ->endpoint(
  114 + /** -------------------- [GET] queries ------------------------------ **/
  115 + ->endpoint(
111 116 ApiEndpoint::factory('/queries', HttpMethods::GET, 'queriesAction')
112 117 ->name('queries')
113 118 ->description('Список запросов, по которым определяется позиция сайта')
... ... @@ -137,8 +142,10 @@ class AllPositionResource extends ApiResource
137 142 ])
138 143 ->allow(AclRoles::USER)
139 144 )
  145 + /** ----------------------------------------------------------------- **/
140 146  
141   - ->endpoint(
  147 + /** -------------------- [GET] queries_group ------------------------ **/
  148 + ->endpoint(
142 149 ApiEndpoint::factory('/queries_group', HttpMethods::GET, 'queriesGroupAction')
143 150 ->name('queries group')
144 151 ->description('Список групп запросов')
... ... @@ -157,8 +164,10 @@ class AllPositionResource extends ApiResource
157 164 ])
158 165 ->allow(AclRoles::USER)
159 166 )
  167 + /** ----------------------------------------------------------------- **/
160 168  
161   - ->endpoint(
  169 + /** -------------------- [GET] report ------------------------------- **/
  170 + ->endpoint(
162 171 ApiEndpoint::factory('/report', HttpMethods::GET, 'reportAction')
163 172 ->name('report')
164 173 ->description('Отчет по позициям сайта')
... ... @@ -219,8 +228,10 @@ class AllPositionResource extends ApiResource
219 228 ])
220 229 ->allow(AclRoles::USER)
221 230 )
  231 + /** ----------------------------------------------------------------- **/
222 232  
223   - ->endpoint(
  233 + /** -------------------- [GET] visibility --------------------------- **/
  234 + ->endpoint(
224 235 ApiEndpoint::factory('/visibility', HttpMethods::GET, 'visibilityAction')
225 236 ->name('visibility')
226 237 ->description('Данные о видимости сайта за указанный период')
... ... @@ -244,6 +255,29 @@ class AllPositionResource extends ApiResource
244 255 ])
245 256 ->allow(AclRoles::USER)
246 257 )
  258 + /** ----------------------------------------------------------------- **/
  259 +
  260 + /** -------------------- [GET] visibility --------------------------- **/
  261 + ->endpoint(
  262 + ApiEndpoint::factory('/report_dates', HttpMethods::GET, 'reportDatesAction')
  263 + ->name('report dates')
  264 + ->description('Список дат, когда обновлялись позиции сайта')
  265 + ->paramsDescription([
  266 + 'required params' => [
  267 + 'project' => 'integer(ID проекта)'
  268 + ],
  269 + ])
  270 + ->exampleResponse([
  271 + "2017-02-13" => "0.2",
  272 + "2017-02-15" => "0.2",
  273 + "2017-02-20" => "0.3",
  274 + "2017-02-26" => "0.3",
  275 + "2017-03-06" => "0.3",
  276 + "2017-03-12" => "0.2"
  277 + ])
  278 + ->allow(AclRoles::USER)
  279 + )
  280 + /** ----------------------------------------------------------------- **/
247 281 ;
248 282  
249 283 }
... ...
app/views/general/documentation.phtml
... ... @@ -27,9 +27,16 @@
27 27  
28 28 <h2>Коллекции</h2>
29 29  
  30 + <div class="list-group">
  31 + <a href="#" class="list-group-item active">
  32 + Анкоры
  33 + </a>
  34 + <a ng-repeat="collection in vm.documentation.collections" href="#{{collection.prefix}}" class="list-group-item">{{collection.name}}</a>
  35 + </div>
  36 +
30 37 <div ng-repeat="collection in vm.documentation.collections">
31 38  
32   - <div class="panel panel-primary">
  39 + <div class="panel panel-primary" id="{{collection.prefix}}">
33 40 <div class="panel-heading">
34 41 {{ collection.name || collection.prefix }}
35 42 </div>
... ...