Changeset 696


Ignore:
Timestamp:
Sep 23, 2014, 9:56:07 PM (10 years ago)
Author:
chronos
Message:
  • Upraveno: Dobu trvání v tabulce NetworkInterfaceUpDown ukládat jako pevné číslo ihned při vkládání. Tím dojde ke zpomalení vkládání, ale zrychlení prohlížení tabulky stavu dostupnosti.
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/Version.php

    r694 r696  
    11<?php
    22
    3 $Revision = 693; // Subversion revision
    4 $DatabaseRevision = 692; // SQL structure revision
    5 $ReleaseTime = strtotime('2014-09-14');
     3$Revision = 696; // Subversion revision
     4$DatabaseRevision = 696; // SQL structure revision
     5$ReleaseTime = strtotime('2014-09-23');
  • trunk/Common/Setup/Updates.php

    r693 r696  
    911911  $Manager->Execute('ALTER TABLE `User` DROP `PhoneNumber`;');
    912912}
     913
     914function UpdateTo696($Manager)
     915{
     916        $Manager->Execute('ALTER TABLE `NetworkInterfaceUpDown` ADD `Duration` INT NOT NULL ;');
     917        $Manager->Execute('UPDATE `NetworkInterfaceUpDown` AS `TM` SET `Duration` = IFNULL(TIMESTAMPDIFF(SECOND,
     918    (SELECT `Time` FROM (SELECT * FROM `NetworkInterfaceUpDown`) AS `TA` WHERE (`TA`.`Time` < `TM`.`Time`)
     919    AND (`TA`.`Interface`=`TM`.`Interface`) ORDER BY `TA`.`Time` DESC LIMIT 1), `TM`.`Time`), 0)');
     920}
     921
    913922
    914923class Updates
     
    962971      679 => array('Revision' => 688, 'Function' => 'UpdateTo688'),
    963972      688 => array('Revision' => 692, 'Function' => 'UpdateTo692'),
     973      692 => array('Revision' => 696, 'Function' => 'UpdateTo696'),
    964974    ));
    965975  }
  • trunk/Modules/NetworkConfigRouterOS/Generators/NetwatchImport.php

    r682 r696  
    5757    {
    5858        // Online state changed
    59       $System->Database->insert('NetworkInterfaceUpDown', array(
    60         'Interface' => $Interface['Id'], 'State' => $Interface['NewOnline'],
    61            'Time' => TimeToMysqlDateTime($StartTime)));
     59      $System->Database->query('INSERT INTO `NetworkInterfaceUpDown` (`Interface`,
     60        `State`, `Time`, `Duration`) VALUES ('.$Interface['Id'].', '.$Interface['NewOnline'].', "'.
     61         TimeToMysqlDateTime($StartTime).'", IFNULL(TIMESTAMPDIFF(SECOND, '.
     62         '(SELECT `Time` FROM `NetworkInterfaceUpDown` AS `TA` WHERE (`TA`.`Time` < "'.TimeToMysqlDateTime($StartTime).'") '.
     63         'AND (`TA`.`Interface`='.$Interface['Id'].') ORDER BY `TA`.`Time` DESC LIMIT 1), "'.TimeToMysqlDateTime($StartTime).'"), 0))');
     64      echo($System->Database->LastQuery."\n");
    6265      $System->Database->update('NetworkInterface', '`Id` = "'.$Interface['Id'].'"',
    6366        array('Online' => $Interface['NewOnline']));
  • trunk/Modules/NetworkConfigRouterOS/NetworkConfigRouterOS.php

    r674 r696  
    3737        'Interface' => array('Type' => 'TNetworkInterface', 'Caption' => 'Rozhraní', 'Default' => '', 'ReadOnly' => true),
    3838        'State' => array('Type' => 'TOnlineState', 'Caption' => 'Stav', 'Default' => '', 'ReadOnly' => true),
    39         'Duration' => array('Type' => 'TimeDiff', 'Caption' => 'Trvání', 'Default' => '', 'ReadOnly' => true,
    40           'SQL' => 'TIMESTAMPDIFF(SECOND, `Time`, '.
    41             '(SELECT `Time` FROM `NetworkInterfaceUpDown` AS `TA` WHERE (`TA`.`Time` > `TX`.`Time`) '.
    42                         'AND (`TA`.`Interface`=`TX`.`Interface`) ORDER BY `TA`.`Time` LIMIT 1))'),
     39        'Duration' => array('Type' => 'TimeDiff', 'Caption' => 'Trvání', 'Default' => '', 'ReadOnly' => true),
    4340      ),
    4441    ));
Note: See TracChangeset for help on using the changeset viewer.