Show
Ignore:
Timestamp:
08/06/09 09:55:30 (3 years ago)
Author:
benoitg
Message:
  • Experimental fix for #596
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/wifidog-auth/wifidog/classes/User.php

    r1409 r1413  
    564564            $sql .= " SUM (CASE WHEN node_id = '".$node->getId()."' THEN (incoming+outgoing) END) AS node_total_bytes, \n"; 
    565565            $sql .= " SUM (timestamp_out - timestamp_in) AS network_duration, \n"; 
    566             $sql .= " SUM (CASE WHEN node_id = '".$node->getId()."' THEN (timestamp_out - timestamp_in) END) AS node_duration \n";//For real 
     566            $sql .= " SUM (CASE WHEN node_id = '".$node->getId()."' THEN (COALESCE(timestamp_out,last_updated) - timestamp_in) END) AS node_duration \n";//For real //The coalesce is to make sure the substraction returns a value for active conections, since active connections do not yet have a timestamp_out.  Do NOT coalesce with CURRENT_TIMESTAMP, it could cause real problems for users in case of gateway crash. 
    567567            $sql .= " FROM connections \n";//For real 
    568568            $sql .= " JOIN nodes USING (node_id) \n";