@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public function total_time() |
72 | 72 | { |
73 | - return round($this->_info['total_time'],3); |
|
73 | + return round($this->_info['total_time'], 3); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function starttransfer_time() |
80 | 80 | { |
81 | - return round($this->_info['starttransfer_time'],3); |
|
81 | + return round($this->_info['starttransfer_time'], 3); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | */ |
87 | 87 | public function connect_time() |
88 | 88 | { |
89 | - return round($this->_info['connect_time'],3); |
|
89 | + return round($this->_info['connect_time'], 3); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function pretransfer_time() |
96 | 96 | { |
97 | - return round($this->_info['pretransfer_time'],3); |
|
97 | + return round($this->_info['pretransfer_time'], 3); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | */ |
290 | 290 | public function rawDataOrJson($format) |
291 | 291 | { |
292 | - if (stripos($format,'json')!==false) |
|
292 | + if (stripos($format, 'json') !== false) |
|
293 | 293 | { |
294 | 294 | return $this->json(); |
295 | 295 | } |
@@ -114,7 +114,9 @@ discard block |
||
114 | 114 | public function getUri() |
115 | 115 | { |
116 | 116 | $proto='http'; |
117 | - if ($this->settings()->isHttps()) $proto='https'; |
|
117 | + if ($this->settings()->isHttps()) { |
|
118 | + $proto='https'; |
|
119 | + } |
|
118 | 120 | |
119 | 121 | return $proto.'://' . $this->_host . ':' . $this->_port; |
120 | 122 | } |
@@ -328,13 +330,19 @@ discard block |
||
328 | 330 | if ($code==200) { |
329 | 331 | $response = curl_multi_getcontent($handle); |
330 | 332 | $header_size = curl_getinfo($handle, CURLINFO_HEADER_SIZE); |
331 | - if (!$header_size) return false; |
|
333 | + if (!$header_size) { |
|
334 | + return false; |
|
335 | + } |
|
332 | 336 | |
333 | 337 | $header = substr($response, 0, $header_size); |
334 | - if (!$header_size) return false; |
|
338 | + if (!$header_size) { |
|
339 | + return false; |
|
340 | + } |
|
335 | 341 | $pos=strrpos($header,'X-ClickHouse-Progress'); |
336 | 342 | |
337 | - if (!$pos) return false; |
|
343 | + if (!$pos) { |
|
344 | + return false; |
|
345 | + } |
|
338 | 346 | |
339 | 347 | $last=substr($header,$pos); |
340 | 348 | $data=@json_decode(str_ireplace('X-ClickHouse-Progress:','',$last),true); |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | /** |
62 | 62 | * @var bool |
63 | 63 | */ |
64 | - private $xClickHouseProgress=false; |
|
64 | + private $xClickHouseProgress = false; |
|
65 | 65 | |
66 | 66 | /** |
67 | 67 | * Http constructor. |
@@ -113,10 +113,10 @@ discard block |
||
113 | 113 | */ |
114 | 114 | public function getUri() |
115 | 115 | { |
116 | - $proto='http'; |
|
117 | - if ($this->settings()->isHttps()) $proto='https'; |
|
116 | + $proto = 'http'; |
|
117 | + if ($this->settings()->isHttps()) $proto = 'https'; |
|
118 | 118 | |
119 | - return $proto.'://' . $this->_host . ':' . $this->_port; |
|
119 | + return $proto . '://' . $this->_host . ':' . $this->_port; |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | } |
186 | 186 | |
187 | 187 | $new->timeOut($this->settings()->getTimeOut()); |
188 | - $new->connectTimeOut($this->_connectTimeOut)->keepAlive();// one sec |
|
188 | + $new->connectTimeOut($this->_connectTimeOut)->keepAlive(); // one sec |
|
189 | 189 | $new->verbose($this->_verbose); |
190 | 190 | |
191 | 191 | return $new; |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | $request = $this->newRequest($extendinfo); |
280 | 280 | $request->url($url); |
281 | 281 | |
282 | - $request->setCallbackFunction(function (CurlerRequest $request) { |
|
282 | + $request->setCallbackFunction(function(CurlerRequest $request) { |
|
283 | 283 | fclose($request->getInfileHandle()); |
284 | 284 | }); |
285 | 285 | |
@@ -322,29 +322,29 @@ discard block |
||
322 | 322 | |
323 | 323 | public function __findXClickHouseProgress($handle) |
324 | 324 | { |
325 | - $code=curl_getinfo($handle,CURLINFO_HTTP_CODE); |
|
325 | + $code = curl_getinfo($handle, CURLINFO_HTTP_CODE); |
|
326 | 326 | |
327 | 327 | // Search X-ClickHouse-Progress |
328 | - if ($code==200) { |
|
328 | + if ($code == 200) { |
|
329 | 329 | $response = curl_multi_getcontent($handle); |
330 | 330 | $header_size = curl_getinfo($handle, CURLINFO_HEADER_SIZE); |
331 | 331 | if (!$header_size) return false; |
332 | 332 | |
333 | 333 | $header = substr($response, 0, $header_size); |
334 | 334 | if (!$header_size) return false; |
335 | - $pos=strrpos($header,'X-ClickHouse-Progress'); |
|
335 | + $pos = strrpos($header, 'X-ClickHouse-Progress'); |
|
336 | 336 | |
337 | 337 | if (!$pos) return false; |
338 | 338 | |
339 | - $last=substr($header,$pos); |
|
340 | - $data=@json_decode(str_ireplace('X-ClickHouse-Progress:','',$last),true); |
|
339 | + $last = substr($header, $pos); |
|
340 | + $data = @json_decode(str_ireplace('X-ClickHouse-Progress:', '', $last), true); |
|
341 | 341 | |
342 | 342 | if ($data && is_callable($this->xClickHouseProgress)) { |
343 | 343 | |
344 | - if (is_array($this->xClickHouseProgress)){ |
|
345 | - call_user_func_array($this->xClickHouseProgress,[$data]); |
|
344 | + if (is_array($this->xClickHouseProgress)) { |
|
345 | + call_user_func_array($this->xClickHouseProgress, [$data]); |
|
346 | 346 | } else { |
347 | - call_user_func($this->xClickHouseProgress,$data); |
|
347 | + call_user_func($this->xClickHouseProgress, $data); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | |
@@ -407,13 +407,13 @@ discard block |
||
407 | 407 | } |
408 | 408 | |
409 | 409 | |
410 | - $request->setResultFileHandle($fout, $isGz)->setCallbackFunction(function (CurlerRequest $request) { |
|
410 | + $request->setResultFileHandle($fout, $isGz)->setCallbackFunction(function(CurlerRequest $request) { |
|
411 | 411 | fclose($request->getResultFileHandle()); |
412 | 412 | }); |
413 | 413 | } |
414 | 414 | if ($this->xClickHouseProgress) |
415 | 415 | { |
416 | - $request->setFunctionProgress([$this,'__findXClickHouseProgress']); |
|
416 | + $request->setFunctionProgress([$this, '__findXClickHouseProgress']); |
|
417 | 417 | } |
418 | 418 | // --------------------------------------------------------------------------------- |
419 | 419 | return $request; |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | */ |
542 | 542 | public function setProgressFunction(callable $callback) |
543 | 543 | { |
544 | - $this->xClickHouseProgress=$callback; |
|
544 | + $this->xClickHouseProgress = $callback; |
|
545 | 545 | } |
546 | 546 | |
547 | 547 | /** |
@@ -493,8 +493,8 @@ |
||
493 | 493 | */ |
494 | 494 | public function getSizeTable($database_table) |
495 | 495 | { |
496 | - $list=[]; |
|
497 | - $nodes=$this->getNodesByTable($database_table); |
|
496 | + $list=[]; |
|
497 | + $nodes=$this->getNodesByTable($database_table); |
|
498 | 498 | // scan need node`s |
499 | 499 | foreach ($nodes as $node) |
500 | 500 | { |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | /** |
43 | 43 | * @var int |
44 | 44 | */ |
45 | - private $scanTimeOut=10; |
|
45 | + private $scanTimeOut = 10; |
|
46 | 46 | |
47 | 47 | /** |
48 | 48 | * @var array |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * |
78 | 78 | * @var array |
79 | 79 | */ |
80 | - private $_table_size_cache=[]; |
|
80 | + private $_table_size_cache = []; |
|
81 | 81 | |
82 | 82 | /** |
83 | 83 | * Cluster constructor. |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | |
192 | 192 | // @todo : rewrite total_replicas=1 если кластер без реплики , нужно проверять какой класте и сколько в нем реплик |
193 | 193 | // if ($replica['total_replicas']<2) {$ok=false;$this->error[]='total_replicas : '.json_encode($replica);} |
194 | - if ($this->softCheck ) |
|
194 | + if ($this->softCheck) |
|
195 | 195 | { |
196 | 196 | if (!$ok) break; |
197 | 197 | continue; |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | $statementsClusters[$node]->getRequest()->setDnsCache(0)->timeOut($this->scanTimeOut)->connectTimeOut($this->scanTimeOut); |
263 | 263 | } |
264 | 264 | $this->defaultClient()->executeAsync(); |
265 | - $tables=[]; |
|
265 | + $tables = []; |
|
266 | 266 | |
267 | 267 | foreach ($this->nodes as $node) { |
268 | 268 | |
@@ -270,16 +270,16 @@ discard block |
||
270 | 270 | try { |
271 | 271 | $r = $statementsReplicas[$node]->rows(); |
272 | 272 | foreach ($r as $row) { |
273 | - $tables[$row['database']][$row['table']][$node] =$row; |
|
273 | + $tables[$row['database']][$row['table']][$node] = $row; |
|
274 | 274 | } |
275 | 275 | $result['replicas'][$node] = $r; |
276 | - } catch (\Exception $E) { |
|
276 | + }catch (\Exception $E) { |
|
277 | 277 | $result['replicas'][$node] = false; |
278 | 278 | $badNodes[$node] = $E->getMessage(); |
279 | 279 | $this->error[] = 'statementsReplicas:' . $E->getMessage(); |
280 | 280 | } |
281 | 281 | // --------------------------------------------------------------------------------------------------- |
282 | - $hosts=[]; |
|
282 | + $hosts = []; |
|
283 | 283 | |
284 | 284 | try { |
285 | 285 | $c = $statementsClusters[$node]->rows(); |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | ]; |
296 | 296 | } |
297 | 297 | |
298 | - } catch (\Exception $E) { |
|
298 | + }catch (\Exception $E) { |
|
299 | 299 | $result['clusters'][$node] = false; |
300 | 300 | |
301 | 301 | $this->error[] = 'clusters:' . $E->getMessage(); |
@@ -360,22 +360,22 @@ discard block |
||
360 | 360 | /** |
361 | 361 | * @return Client |
362 | 362 | */ |
363 | - public function clientLike($cluster,$ip_addr_like) |
|
363 | + public function clientLike($cluster, $ip_addr_like) |
|
364 | 364 | { |
365 | - $nodes_check=$this->nodes; |
|
366 | - $nodes=$this->getClusterNodes($cluster); |
|
367 | - $list_ips_need=explode(';',$ip_addr_like); |
|
368 | - $find=false; |
|
369 | - foreach($list_ips_need as $like) |
|
365 | + $nodes_check = $this->nodes; |
|
366 | + $nodes = $this->getClusterNodes($cluster); |
|
367 | + $list_ips_need = explode(';', $ip_addr_like); |
|
368 | + $find = false; |
|
369 | + foreach ($list_ips_need as $like) |
|
370 | 370 | { |
371 | 371 | foreach ($nodes as $node) |
372 | 372 | { |
373 | 373 | |
374 | - if (stripos($node,$like)!==false) |
|
374 | + if (stripos($node, $like) !== false) |
|
375 | 375 | { |
376 | - if (in_array($node,$nodes_check)) |
|
376 | + if (in_array($node, $nodes_check)) |
|
377 | 377 | { |
378 | - $find=$node; |
|
378 | + $find = $node; |
|
379 | 379 | } |
380 | 380 | else |
381 | 381 | { |
@@ -387,8 +387,8 @@ discard block |
||
387 | 387 | } |
388 | 388 | if ($find) break; |
389 | 389 | } |
390 | - if (!$find){ |
|
391 | - $find=$nodes[0]; |
|
390 | + if (!$find) { |
|
391 | + $find = $nodes[0]; |
|
392 | 392 | } |
393 | 393 | return $this->client($find); |
394 | 394 | } |
@@ -462,10 +462,10 @@ discard block |
||
462 | 462 | * |
463 | 463 | * @return array |
464 | 464 | */ |
465 | - public function getTables($resultDetail=false) |
|
465 | + public function getTables($resultDetail = false) |
|
466 | 466 | { |
467 | 467 | $this->connect(); |
468 | - $list=[]; |
|
468 | + $list = []; |
|
469 | 469 | foreach ($this->tables as $db_name=>$tables) |
470 | 470 | { |
471 | 471 | foreach ($tables as $table_name=>$nodes) |
@@ -473,11 +473,11 @@ discard block |
||
473 | 473 | |
474 | 474 | if ($resultDetail) |
475 | 475 | { |
476 | - $list[$db_name.'.'.$table_name]=$nodes; |
|
476 | + $list[$db_name . '.' . $table_name] = $nodes; |
|
477 | 477 | } |
478 | 478 | else |
479 | 479 | { |
480 | - $list[$db_name.'.'.$table_name]=array_keys($nodes); |
|
480 | + $list[$db_name . '.' . $table_name] = array_keys($nodes); |
|
481 | 481 | } |
482 | 482 | } |
483 | 483 | } |
@@ -493,24 +493,24 @@ discard block |
||
493 | 493 | */ |
494 | 494 | public function getSizeTable($database_table) |
495 | 495 | { |
496 | - $list=[]; |
|
497 | - $nodes=$this->getNodesByTable($database_table); |
|
496 | + $list = []; |
|
497 | + $nodes = $this->getNodesByTable($database_table); |
|
498 | 498 | // scan need node`s |
499 | 499 | foreach ($nodes as $node) |
500 | 500 | { |
501 | 501 | if (empty($this->_table_size_cache[$node])) |
502 | 502 | { |
503 | - $this->_table_size_cache[$node]=$this->client($node)->tablesSize(true); |
|
503 | + $this->_table_size_cache[$node] = $this->client($node)->tablesSize(true); |
|
504 | 504 | } |
505 | 505 | } |
506 | 506 | |
507 | - $sizes=[]; |
|
507 | + $sizes = []; |
|
508 | 508 | foreach ($this->_table_size_cache as $node=>$rows) |
509 | 509 | { |
510 | 510 | foreach ($rows as $row) |
511 | 511 | { |
512 | - $sizes[$row['database'].'.'.$row['table']][$node]=$row; |
|
513 | - @$sizes[$row['database'].'.'.$row['table']]['total']['sizebytes']+=$row['sizebytes']; |
|
512 | + $sizes[$row['database'] . '.' . $row['table']][$node] = $row; |
|
513 | + @$sizes[$row['database'] . '.' . $row['table']]['total']['sizebytes'] += $row['sizebytes']; |
|
514 | 514 | |
515 | 515 | |
516 | 516 | |
@@ -531,17 +531,17 @@ discard block |
||
531 | 531 | * @param $database_table |
532 | 532 | * @return array |
533 | 533 | */ |
534 | - public function truncateTable($database_table,$timeOut=2000) |
|
534 | + public function truncateTable($database_table, $timeOut = 2000) |
|
535 | 535 | { |
536 | - $out=[]; |
|
537 | - list($db,$table)=explode('.',$database_table); |
|
538 | - $nodes=$this->getMasterNodeForTable($database_table); |
|
536 | + $out = []; |
|
537 | + list($db, $table) = explode('.', $database_table); |
|
538 | + $nodes = $this->getMasterNodeForTable($database_table); |
|
539 | 539 | // scan need node`s |
540 | 540 | foreach ($nodes as $node) |
541 | 541 | { |
542 | - $def=$this->client($node)->getTimeout(); |
|
542 | + $def = $this->client($node)->getTimeout(); |
|
543 | 543 | $this->client($node)->database($db)->setTimeout($timeOut); |
544 | - $out[$node]=$this->client($node)->truncateTable($table); |
|
544 | + $out[$node] = $this->client($node)->truncateTable($table); |
|
545 | 545 | $this->client($node)->setTimeout($def); |
546 | 546 | } |
547 | 547 | return $out; |
@@ -555,15 +555,15 @@ discard block |
||
555 | 555 | */ |
556 | 556 | public function getMasterNodeForTable($database_table) |
557 | 557 | { |
558 | - $list=$this->getTables(true); |
|
558 | + $list = $this->getTables(true); |
|
559 | 559 | |
560 | 560 | if (empty($list[$database_table])) return []; |
561 | 561 | |
562 | 562 | |
563 | - $result=[]; |
|
563 | + $result = []; |
|
564 | 564 | foreach ($list[$database_table] as $node=>$row) |
565 | 565 | { |
566 | - if ($row['is_leader']) $result[]=$node; |
|
566 | + if ($row['is_leader']) $result[] = $node; |
|
567 | 567 | } |
568 | 568 | return $result; |
569 | 569 | } |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | */ |
576 | 576 | public function getNodesByTable($database_table) |
577 | 577 | { |
578 | - $list=$this->getTables(); |
|
578 | + $list = $this->getTables(); |
|
579 | 579 | if (empty($list[$database_table])) { |
580 | 580 | throw new QueryException('Not find :' . $database_table); |
581 | 581 | } |
@@ -193,7 +193,9 @@ discard block |
||
193 | 193 | // if ($replica['total_replicas']<2) {$ok=false;$this->error[]='total_replicas : '.json_encode($replica);} |
194 | 194 | if ($this->softCheck ) |
195 | 195 | { |
196 | - if (!$ok) break; |
|
196 | + if (!$ok) { |
|
197 | + break; |
|
198 | + } |
|
197 | 199 | continue; |
198 | 200 | } |
199 | 201 | |
@@ -209,7 +211,9 @@ discard block |
||
209 | 211 | $ok = false; |
210 | 212 | $this->error[] = 'log_max_index : ' . json_encode($replica); |
211 | 213 | } |
212 | - if (!$ok) break; |
|
214 | + if (!$ok) { |
|
215 | + break; |
|
216 | + } |
|
213 | 217 | } |
214 | 218 | return $ok; |
215 | 219 | } |
@@ -308,7 +312,9 @@ discard block |
||
308 | 312 | // Let's check that replication goes well |
309 | 313 | $rIsOk = $this->isReplicasWork($result['replicas'][$node]); |
310 | 314 | $result['replicasIsOk'][$node] = $rIsOk; |
311 | - if (!$rIsOk) $replicasIsOk = false; |
|
315 | + if (!$rIsOk) { |
|
316 | + $replicasIsOk = false; |
|
317 | + } |
|
312 | 318 | // --------------------------------------------------------------------------------------------------- |
313 | 319 | } |
314 | 320 | |
@@ -328,7 +334,9 @@ discard block |
||
328 | 334 | $this->error[] = 'Have bad node : ' . json_encode($this->badNodes); |
329 | 335 | $this->replicasIsOk = false; |
330 | 336 | } |
331 | - if (!sizeof($this->error)) $this->error = false; |
|
337 | + if (!sizeof($this->error)) { |
|
338 | + $this->error = false; |
|
339 | + } |
|
332 | 340 | $this->resultScan = $result; |
333 | 341 | // @todo : We connect to everyone in the DNS list, we need to decry that the requests were returned by all the hosts to which we connected |
334 | 342 | return $this; |
@@ -376,16 +384,19 @@ discard block |
||
376 | 384 | if (in_array($node,$nodes_check)) |
377 | 385 | { |
378 | 386 | $find=$node; |
379 | - } |
|
380 | - else |
|
387 | + } else |
|
381 | 388 | { |
382 | 389 | // node exists on cluster, but not check |
383 | 390 | } |
384 | 391 | |
385 | 392 | } |
386 | - if ($find) break; |
|
393 | + if ($find) { |
|
394 | + break; |
|
395 | + } |
|
396 | + } |
|
397 | + if ($find) { |
|
398 | + break; |
|
387 | 399 | } |
388 | - if ($find) break; |
|
389 | 400 | } |
390 | 401 | if (!$find){ |
391 | 402 | $find=$nodes[0]; |
@@ -435,7 +446,9 @@ discard block |
||
435 | 446 | public function getClusterInfoTable($cluster) |
436 | 447 | { |
437 | 448 | $this->connect(); |
438 | - if (empty($this->resultScan['cluster.list'][$cluster])) throw new QueryException('Cluster not find:' . $cluster); |
|
449 | + if (empty($this->resultScan['cluster.list'][$cluster])) { |
|
450 | + throw new QueryException('Cluster not find:' . $cluster); |
|
451 | + } |
|
439 | 452 | return $this->resultScan['cluster.list'][$cluster]; |
440 | 453 | } |
441 | 454 | |
@@ -474,8 +487,7 @@ discard block |
||
474 | 487 | if ($resultDetail) |
475 | 488 | { |
476 | 489 | $list[$db_name.'.'.$table_name]=$nodes; |
477 | - } |
|
478 | - else |
|
490 | + } else |
|
479 | 491 | { |
480 | 492 | $list[$db_name.'.'.$table_name]=array_keys($nodes); |
481 | 493 | } |
@@ -557,13 +569,17 @@ discard block |
||
557 | 569 | { |
558 | 570 | $list=$this->getTables(true); |
559 | 571 | |
560 | - if (empty($list[$database_table])) return []; |
|
572 | + if (empty($list[$database_table])) { |
|
573 | + return []; |
|
574 | + } |
|
561 | 575 | |
562 | 576 | |
563 | 577 | $result=[]; |
564 | 578 | foreach ($list[$database_table] as $node=>$row) |
565 | 579 | { |
566 | - if ($row['is_leader']) $result[]=$node; |
|
580 | + if ($row['is_leader']) { |
|
581 | + $result[]=$node; |
|
582 | + } |
|
567 | 583 | } |
568 | 584 | return $result; |
569 | 585 | } |
@@ -16,12 +16,12 @@ discard block |
||
16 | 16 | */ |
17 | 17 | private $settings = []; |
18 | 18 | |
19 | - private $_ReadOnlyUser=false; |
|
19 | + private $_ReadOnlyUser = false; |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * @var bool |
23 | 23 | */ |
24 | - private $_isHttps=false; |
|
24 | + private $_isHttps = false; |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * Settings constructor. |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | } |
117 | 117 | |
118 | 118 | |
119 | - public function https($flag=true) |
|
119 | + public function https($flag = true) |
|
120 | 120 | { |
121 | 121 | $this->set('https', $flag); |
122 | 122 | return $this; |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | */ |
202 | 202 | public function setReadOnlyUser($flag) |
203 | 203 | { |
204 | - $this->_ReadOnlyUser=$flag; |
|
204 | + $this->_ReadOnlyUser = $flag; |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
@@ -152,7 +152,9 @@ |
||
152 | 152 | */ |
153 | 153 | public function getSessionId() |
154 | 154 | { |
155 | - if (empty($this->settings['session_id'])) return false; |
|
155 | + if (empty($this->settings['session_id'])) { |
|
156 | + return false; |
|
157 | + } |
|
156 | 158 | return $this->get('session_id'); |
157 | 159 | } |
158 | 160 |
@@ -57,14 +57,14 @@ |
||
57 | 57 | [time(), 'CLICKS', 1, 1237, '192.168.1.11', 'Moscow', 'user_11', ''], |
58 | 58 | [time(), 'CLICKS', 1, 1237, '192.168.1.13', 'Moscow', 'user_13', ''], |
59 | 59 | [time(), 'CLICKS', 1, 1237, '192.168.1.14', 'Moscow', 'user_14', ''], |
60 | - [time(), 'VIEWS', 1, 1237, '192.168.1.11', 'Moscow', 'user_11', ''], |
|
61 | - [time(), 'VIEWS', 1, 1237, '192.168.1.12', 'Moscow', 'user_12', ''], |
|
62 | - |
|
63 | - [time(), 'VIEWS', 1, 1237, '192.168.1.1', 'Rwanda', 'user_55', 'http://smi2.ru?utm_campaign=abc'], |
|
64 | - [time(), 'VIEWS', 1, 1237, '192.168.1.1', 'Banaadir', 'user_54', 'http://smi2.ru?utm_campaign=abc'], |
|
65 | - [time(), 'VIEWS', 1, 1237, '192.168.1.1', 'Tobruk', 'user_32', 'http://smi2.ru?utm_campaign=CM1'], |
|
66 | - [time(), 'VIEWS', 1, 1237, '192.168.1.1', 'Gisborne', 'user_12', 'http://smi2.ru?utm_campaign=CM1'], |
|
67 | - [time(), 'VIEWS', 1, 1237, '192.168.1.1', 'Moscow', 'user_43', 'http://smi2.ru?utm_campaign=CM3'], |
|
60 | + [time(), 'VIEWS', 1, 1237, '192.168.1.11', 'Moscow', 'user_11', ''], |
|
61 | + [time(), 'VIEWS', 1, 1237, '192.168.1.12', 'Moscow', 'user_12', ''], |
|
62 | + |
|
63 | + [time(), 'VIEWS', 1, 1237, '192.168.1.1', 'Rwanda', 'user_55', 'http://smi2.ru?utm_campaign=abc'], |
|
64 | + [time(), 'VIEWS', 1, 1237, '192.168.1.1', 'Banaadir', 'user_54', 'http://smi2.ru?utm_campaign=abc'], |
|
65 | + [time(), 'VIEWS', 1, 1237, '192.168.1.1', 'Tobruk', 'user_32', 'http://smi2.ru?utm_campaign=CM1'], |
|
66 | + [time(), 'VIEWS', 1, 1237, '192.168.1.1', 'Gisborne', 'user_12', 'http://smi2.ru?utm_campaign=CM1'], |
|
67 | + [time(), 'VIEWS', 1, 1237, '192.168.1.1', 'Moscow', 'user_43', 'http://smi2.ru?utm_campaign=CM3'], |
|
68 | 68 | ], |
69 | 69 | ['event_time', 'event_type', 'site_id', 'article_id', 'ip', 'city', 'user_uuid', 'referer'] |
70 | 70 | ); |
@@ -68,7 +68,9 @@ |
||
68 | 68 | 'utm' => $userEvent->getUtm(), |
69 | 69 | ]; |
70 | 70 | file_put_contents($fileName, \ClickHouseDB\FormatLine::TSV($row) . "\n", FILE_APPEND); |
71 | - if ($z % 100 == 0) echo "$z\r"; |
|
71 | + if ($z % 100 == 0) { |
|
72 | + echo "$z\r"; |
|
73 | + } |
|
72 | 74 | } |
73 | 75 | |
74 | 76 |
@@ -56,14 +56,14 @@ |
||
56 | 56 | [time(), 'CLICKS', 1, 1237, '192.168.1.13', 'Moscow', 'user_13', ''], |
57 | 57 | [time(), 'CLICKS', 1, 1237, '192.168.1.14', 'Moscow', 'user_14', ''], |
58 | 58 | |
59 | - [time(), 'VIEWS', 1, 1237, '192.168.1.11', 'Moscow', 'user_11', ''], |
|
60 | - [time(), 'VIEWS', 1, 1237, '192.168.1.12', 'Moscow', 'user_12', ''], |
|
61 | - |
|
62 | - [time(), 'VIEWS', 1, 27, '192.168.1.1', 'Rwanda', 'user_55', 'http://smi2.ru?utm_campaign=abc'], |
|
63 | - [time(), 'VIEWS', 1, 27, '192.168.1.1', 'Banaadir', 'user_54', 'http://smi2.ru?utm_campaign=abc'], |
|
64 | - [time(), 'VIEWS', 1, 27, '192.168.1.1', 'Tobruk', 'user_32', 'http://smi2.ru?utm_campaign=CM1'], |
|
65 | - [time(), 'VIEWS', 1, 28, '192.168.1.1', 'Gisborne', 'user_12', 'http://smi2.ru?utm_campaign=CM1'], |
|
66 | - [time(), 'VIEWS', 1, 26, '192.168.1.1', 'Moscow', 'user_43', 'http://smi2.ru?utm_campaign=CM3'], |
|
59 | + [time(), 'VIEWS', 1, 1237, '192.168.1.11', 'Moscow', 'user_11', ''], |
|
60 | + [time(), 'VIEWS', 1, 1237, '192.168.1.12', 'Moscow', 'user_12', ''], |
|
61 | + |
|
62 | + [time(), 'VIEWS', 1, 27, '192.168.1.1', 'Rwanda', 'user_55', 'http://smi2.ru?utm_campaign=abc'], |
|
63 | + [time(), 'VIEWS', 1, 27, '192.168.1.1', 'Banaadir', 'user_54', 'http://smi2.ru?utm_campaign=abc'], |
|
64 | + [time(), 'VIEWS', 1, 27, '192.168.1.1', 'Tobruk', 'user_32', 'http://smi2.ru?utm_campaign=CM1'], |
|
65 | + [time(), 'VIEWS', 1, 28, '192.168.1.1', 'Gisborne', 'user_12', 'http://smi2.ru?utm_campaign=CM1'], |
|
66 | + [time(), 'VIEWS', 1, 26, '192.168.1.1', 'Moscow', 'user_43', 'http://smi2.ru?utm_campaign=CM3'], |
|
67 | 67 | ], |
68 | 68 | ['event_time', 'event_type', 'site_id', 'article_id', 'ip', 'city', 'user_uuid', 'referer'] |
69 | 69 | ); |