Changeset 6f65b602add1372fe24881cc8c62d7339d220045

Show
Ignore:
Timestamp:
10/15/08 03:06:54 (6 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1224040014 +0000
git-parent:

[33c2ab0523908e7bc243de0779d11128fb79580d]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1224040014 +0000
Message:

flot shows UTC, so we'll back (asswards) into it from the DB time zone, refs #22

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • ui/web/lib/Reconnoiter_DB.php

    r0204315 r6f65b60  
    55class Reconnoiter_DB { 
    66  private $db; 
     7  private $time_kludge; 
    78 
    89  function __construct() { 
     10    $this->time_kludge = "(? ::timestamp::text || '-00')::timestamptz"; 
    911  } 
    1012  function getDB() { 
     
    2325  } 
    2426 
     27  // Crazy extract syntax to pull out the timestamps so that it looks like the current timezone, but in UTC 
    2528  function get_data_for_window($uuid, $name, $start, $end, $expected, $derive) { 
    2629    $type = preg_match('/^\d+$/', $uuid) ? '::integer' : '::uuid'; 
    27     $sth = $this->db->prepare("select sid, name, extract(epoch from rollup_time) as rollup_time, count_rows, avg_value, counter_dev from stratcon.fetch_dataset(? $type,?,?,?,?,?)"); 
     30    $sth = $this->db->prepare(" 
     31      select sid, name, extract(epoch from 
     32                                (rollup_time::timestamp::text || '-00') 
     33                                  ::timestamptz) as rollup_time, 
     34             count_rows, avg_value, counter_dev 
     35        from stratcon.fetch_dataset( 
     36               ? $type,?, 
     37               $this->time_kludge, 
     38               $this->time_kludge, 
     39               ?,? 
     40             )"); 
    2841    $sth->execute(array($uuid,$name,$start,$end,$expected,$derive)); 
    2942    $rv = array(); 
     
    3447  } 
    3548  function get_var_for_window($uuid, $name, $start, $end, $expected) { 
    36     $sth = preg_match('/^\d+$/', $uuid) ? 
    37       $this->db->prepare("select sid, extract(epoch from whence) as whence, name, value from stratcon.fetch_varset(? ::int,?,?,?,?)") : 
    38       $this->db->prepare("select sid, extract(epoch from whence) as whence, name, value from stratcon.fetch_varset(? ::uuid,?,?,?,?)"); 
     49    $type = preg_match('/^\d+$/', $uuid) ? "::int" : "::uuid"; 
     50    $sth = $this->db->prepare(" 
     51      select sid, extract(epoch from 
     52                          (whence::timestamp::text || '-00') 
     53                          ::timestamptz) as whence, 
     54             name, value 
     55        from stratcon.fetch_varset( 
     56               ? $type,?,$this->time_kludge,$this->time_kludge,? 
     57             )"); 
    3958    $sth->execute(array($uuid,$name,$start,$end,$expected)); 
    4059    $rv = array();