Przeglądaj źródła

Merge branch 'feature-stats-character' into 'master'

Changed method that get cache to check before if redis is working, and...

See merge request interlink-sa/flowdat3/modules/stats!58
Jean Sumara Leopoldo 5 lat temu
rodzic
commit
cdd80297d1
1 zmienionych plików z 17 dodań i 4 usunięć
  1. 17 4
      src/StatsBundle/Controller/StatsController.php

+ 17 - 4
src/StatsBundle/Controller/StatsController.php

@@ -1785,7 +1785,19 @@ class StatsController extends Controller
         $cers = $snrs = $utilizations = $errors = $series = $targets = array();
 
         $key = "olt_scan_card_{$prefix}";
-        $dataCached = $redis->get($key);
+        $getCache = false;
+
+        try{
+            if($redis->ping() == "PONG"){
+                $getCache = true;
+            }
+        }catch (\Exception $e){
+            $getCache = false;
+        }
+
+        if($getCache){
+            $dataCached = $redis->get($key);
+        }
 
         /* % cpu & memory cards */
         (isset($dataCached['cpu'])) ? $cpu = $dataCached['cpu'] : $cpu = array();
@@ -1908,20 +1920,21 @@ class StatsController extends Controller
 
     public function onuSignal($oltDeviceId, $serverId)
     {
-
         $em = $this->get('doctrine')->getManager();
         $onus = $em->getRepository('StatsBundle:Onu')->createQueryBuilder('o')
             ->select('o.txPower', 'o.rxPowerOlt', 'o.ponSerialNumber')
             ->where('o.deviceServer = :serverId')
             ->andWhere('o.oltDeviceId = :oltDeviceId')
+            ->andWhere('o.txPower IS NOT NULL')
+            ->andWhere('o.rxPowerOlt IS NOT NULL')
             ->setParameter('serverId', $serverId)
             ->setParameter('oltDeviceId', $oltDeviceId)
             ->getQuery()->getResult();
 
-        $colors = $signals = array();
+        $signals = array();
 
         foreach ($onus as $data) {
-            if ($data['txPower'] == null || $data['rxPowerOlt'] == null) continue;
+            if (preg_match("/^[a-zA-Z0-9]+$/", $data['ponSerialNumber']) != 1) continue;
 
             $color = $this->getOnuRxColor($data['rxPowerOlt']);