Changeset 862


Ignore:
Timestamp:
Oct 4, 2019, 9:37:59 AM (5 years ago)
Author:
chronos
Message:
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/UpdateTrace.php

    r855 r862  
    20562056  $Manager->Execute('ALTER TABLE `NetworkDeviceLog`
    20572057    ADD CONSTRAINT `NetworkDeviceLog_ibfk_1` FOREIGN KEY (`Device`) REFERENCES `NetworkDevice` (`Id`);');
     2058}
     2059
     2060function UpdateTo862($Manager)
     2061{
     2062  $Manager->Execute('ALTER TABLE `NetworkInterfaceUpDown` ADD `Previous` INT NULL AFTER `Duration`');
     2063  $Manager->Execute('ALTER TABLE `NetworkInterfaceUpDown` ADD INDEX ( `Previous` )');
     2064  $Manager->Execute('UPDATE `NetworkInterfaceUpDown` AS T1, `NetworkInterfaceUpDown` AS T2 SET T1.Previous = T2.Id WHERE (T1.Previous IS NULL) AND (T2.Interface=T1.Interface) AND (T1.Time = DATE_ADD(T2.Time, INTERVAL T2.Duration SECOND))');
    20582065}
    20592066
     
    21542161      838 => array('Revision' => 844, 'Function' => 'UpdateTo844'),
    21552162      844 => array('Revision' => 855, 'Function' => 'UpdateTo855'),
     2163      855 => array('Revision' => 862, 'Function' => 'UpdateTo862'),
    21562164    ));
    21572165  }
  • trunk/Application/Version.php

    r858 r862  
    11<?php
    22
    3 $Revision = 857; // Subversion revision
    4 $DatabaseRevision = 855; // SQL structure revision
    5 $ReleaseTime = strtotime('2019-05-08');
     3$Revision = 862; // Subversion revision
     4$DatabaseRevision = 862; // SQL structure revision
     5$ReleaseTime = strtotime('2019-10-04');
  • trunk/Modules/NetworkConfigRouterOS/Generators/NetwatchImport.php

    r861 r862  
    4444    $Queries = array();
    4545    $QueriesInsert = array();
    46     $QueriesUpdate = array();
    4746    foreach($Interfaces as $Index => $Interface)
    4847    {
     
    5655        // Online state changed
    5756        $QueriesInsert[] = 'INSERT INTO `NetworkInterfaceUpDown` (`Interface`,'.
    58           '`State`, `Time`, `Duration`) VALUES ('.$Interface['Id'].', '.$Interface['NewOnline'].', "'.
    59           TimeToMysqlDateTime($StartTime).'", NULL)';
    60         // Update previous record duration in UpDown table
    61         $QueriesUpdate[] = 'UPDATE `NetworkInterfaceUpDown` AS `TM` SET `Duration` = TIMESTAMPDIFF(SECOND, '.
    62           '`TM`.`Time`, (SELECT `Time` FROM (SELECT * FROM `NetworkInterfaceUpDown`) AS `TA` WHERE (`TA`.`Time` > `TM`.`Time`) '.
    63           'AND (`TA`.`Interface`=`TM`.`Interface`) ORDER BY `TA`.`Time` ASC LIMIT 1)) '.
    64           'WHERE (`TM`.`Duration` IS NULL) AND (`TM`.`Interface` ='.$Interface['Id'].')';
     57          '`State`, `Time`, `Previous`) VALUES ('.$Interface['Id'].', '.$Interface['NewOnline'].', "'.
     58          TimeToMysqlDateTime($StartTime).'", (SELECT MAX(T2.Id) FROM NetworkInterfaceUpDown AS T2 WHERE T2.Interface='.$Interface['Id'].'))';
    6559        $Queries[] = $this->Database->GetUpdate('NetworkInterface', '`Id` = "'.$Interface['Id'].'"',
    6660          array('Online' => $Interface['NewOnline']));
     
    7367    $this->Database->Transaction($Queries);
    7468    echo("done\n");
    75     echo("transakce\n");
    76     $this->Database->Transaction($QueriesUpdate);
    77     echo("done\n");
     69
     70    // Update Duration for new items
     71    $this->Database->query('UPDATE NetworkInterfaceUpDown AS T1, NetworkInterfaceUpDown AS T2 SET T1.Duration = TIMESTAMPDIFF(SECOND, T1.Time, T2.Time) WHERE (T2.Previous = T1.Id) AND (T2.Interface = T1.Interface) AND (T1.Duration IS NULL)');
    7872
    7973    // Set offline all interfaces which were not updated as online
Note: See TracChangeset for help on using the changeset viewer.