fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [7590] property: tuning


From: Sigurd Nes
Subject: [Fmsystem-commits] [7590] property: tuning
Date: Wed, 14 Sep 2011 19:24:59 +0000

Revision: 7590
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=7590
Author:   sigurdne
Date:     2011-09-14 19:24:58 +0000 (Wed, 14 Sep 2011)
Log Message:
-----------
property: tuning

Modified Paths:
--------------
    trunk/property/inc/class.bocommon.inc.php
    trunk/property/inc/class.soentity.inc.php
    trunk/property/inc/class.solocation.inc.php
    trunk/property/inc/class.sotts.inc.php

Modified: trunk/property/inc/class.bocommon.inc.php
===================================================================
--- trunk/property/inc/class.bocommon.inc.php   2011-09-14 16:45:50 UTC (rev 
7589)
+++ trunk/property/inc/class.bocommon.inc.php   2011-09-14 19:24:58 UTC (rev 
7590)
@@ -1163,7 +1163,7 @@
                                {
                                        $type_id        = 
count($location_types);
                                }
-
+                               $cols.= ",fm_location1.loc1_name";
                                $this->join = $this->socommon->join;
                                $joinmethod .= " $this->join  fm_location1 ON 
($entity_table.loc1 = fm_location1.loc1))";
                                $paranthesis .='(';

Modified: trunk/property/inc/class.soentity.inc.php
===================================================================
--- trunk/property/inc/class.soentity.inc.php   2011-09-14 16:45:50 UTC (rev 
7589)
+++ trunk/property/inc/class.soentity.inc.php   2011-09-14 19:24:58 UTC (rev 
7590)
@@ -154,7 +154,7 @@
                                $cols_return_extra      = array();
                                $cols_return            = array();
                                $uicols                         = array();
-                               $cols                           = $entity_table 
. '.*';
+                               $cols                           = 
"{$entity_table}.*";
 
                                $cols_return[]                          = 
'location_code';
                                $uicols['input_type'][]         = 'hidden';
@@ -208,7 +208,7 @@
                                        $uicols['classname'][]          = '';
                                }
 
-                               $cols .= ", {$entity_table}.user_id";
+               //              $cols .= ", {$entity_table}.user_id";
                                $cols_return[]                          = 
'user_id';
 
                                $cols_return_extra[]= array
@@ -223,7 +223,7 @@
 
                                $sql = 
$this->bocommon->generate_sql(array('entity_table'=>$entity_table,'cols_return'=>$cols_return,'cols'=>$cols,
                                        
'uicols'=>$uicols,'joinmethod'=>$joinmethod,'paranthesis'=>$paranthesis,'query'=>$query,'lookup'=>$lookup,'location_level'=>$category['location_level']));
-                               $sql =  str_replace('SELECT', 'SELECT 
DISTINCT',$sql);
+                               //$sql =        str_replace('SELECT', 'SELECT 
DISTINCT',$sql);
 
                                
$this->bocommon->fm_cache("sql_{$this->type}_{$entity_id}_{$cat_id}_{$lookup}", 
$sql);
                                
$this->bocommon->fm_cache("uicols_{$this->type}_{$entity_id}_{$cat_id}_{$lookup}",
 $this->bocommon->uicols);
@@ -546,9 +546,35 @@
                        $sql .= " $filtermethod $querymethod";
 
 //_debug_array($sql);
-                       $this->db->query("SELECT DISTINCT {$entity_table}.id " 
. substr($sql,strripos($sql,'from')),__LINE__,__FILE__);
-                       $this->total_records = $this->db->num_rows();
 
+                       $cache_info = 
phpgwapi_cache::session_get('property',"{$entity_table}_listing_metadata");
+
+                       if (!isset($cache_info['sql_hash']) || 
$cache_info['sql_hash'] != md5($sql))
+                       {
+                               $cache_info = array();
+                       }
+                       
+                       if(!$cache_info)
+                       {
+                               $sql_cnt = "SELECT DISTINCT {$entity_table}.id 
" . substr($sql,strripos($sql,'FROM'));
+                               $sql2 = "SELECT count(*) as cnt FROM 
({$sql_cnt}) as t";
+
+                               $this->db->query($sql2,__LINE__,__FILE__);
+                               $this->db->next_record();
+                               unset($sql2);
+                               unset($sql_cnt);
+
+                               $cache_info = array
+                               (
+                                       'total_records'         => 
$this->db->f('cnt'),
+                                       'sql_hash'                      => 
md5($sql)
+                               );
+                               
phpgwapi_cache::session_set('property',"{$entity_table}_listing_metadata",$cache_info);
+                       }
+
+                       $this->total_records    = $cache_info['total_records'];
+
+
                        if($dry_run)
                        {
                                return array();

Modified: trunk/property/inc/class.solocation.inc.php
===================================================================
--- trunk/property/inc/class.solocation.inc.php 2011-09-14 16:45:50 UTC (rev 
7589)
+++ trunk/property/inc/class.solocation.inc.php 2011-09-14 19:24:58 UTC (rev 
7590)
@@ -861,10 +861,32 @@
                        $sql .= "$filtermethod $querymethod";
 
                        $values = array();
-                       $this->db->query('SELECT count(*) AS cnt ' . 
substr($sql,strripos($sql,' from')),__LINE__,__FILE__);
-                       $this->db->next_record();
-                       $this->total_records = $this->db->f('cnt');
+//                     $this->db->query('SELECT count(*) AS cnt ' . 
substr($sql,strripos($sql,' from')),__LINE__,__FILE__);
+//                     $this->db->next_record();
+//                     $this->total_records = $this->db->f('cnt');
 
+                       $cache_info = 
phpgwapi_cache::session_get('property',"location{$type_id}_listing_metadata");
+
+                       if (!isset($cache_info['sql_hash']) || 
$cache_info['sql_hash'] != md5($sql))
+                       {
+                               $cache_info = array();
+                       }
+                       
+                       if(!$cache_info)
+                       {
+                               $this->db->query('SELECT count(*) AS cnt ' . 
substr($sql,strripos($sql,' from')),__LINE__,__FILE__);
+                               $this->db->next_record();
+
+                               $cache_info = array
+                               (
+                                       'total_records'         => 
$this->db->f('cnt'),
+                                       'sql_hash'                      => 
md5($sql)
+                               );
+                               
phpgwapi_cache::session_set('property',"location{$type_id}_listing_metadata",$cache_info);
+                       }
+
+                       $this->total_records    = $cache_info['total_records'];
+
                        //address@hidden 23/07/08 avoid retrieve data in first 
time, only render definition for headers (var myColumnDefs)
                        if($dry_run)
                        {

Modified: trunk/property/inc/class.sotts.inc.php
===================================================================
--- trunk/property/inc/class.sotts.inc.php      2011-09-14 16:45:50 UTC (rev 
7589)
+++ trunk/property/inc/class.sotts.inc.php      2011-09-14 19:24:58 UTC (rev 
7590)
@@ -457,14 +457,34 @@
 
 //_debug_array($sql);
 
-                       $sql2 = "SELECT count(*) as cnt, sum(budget) as 
sum_budget, sum(actual_cost) as sum_actual_cost FROM ({$sql_cnt}) as t";
-                       $this->db->query($sql2,__LINE__,__FILE__);
-                       $this->db->next_record();
-                       $this->total_records    = $this->db->f('cnt');
-                       $this->sum_budget               = 
$this->db->f('sum_budget');
-                       $this->sum_actual_cost  = 
$this->db->f('sum_actual_cost');
-                       unset($sql2);
+                       $cache_info = 
phpgwapi_cache::session_get('property','tts_listing_metadata');
 
+                       if (!isset($cache_info['sql_hash']) || 
$cache_info['sql_hash'] != md5($sql_cnt))
+                       {
+                               $cache_info = array();
+                       }
+                       
+                       if(!$cache_info)
+                       {
+                               $sql2 = "SELECT count(*) as cnt, sum(budget) as 
sum_budget, sum(actual_cost) as sum_actual_cost FROM ({$sql_cnt}) as t";
+                               $this->db->query($sql2,__LINE__,__FILE__);
+                               $this->db->next_record();
+                               unset($sql2);
+
+                               $cache_info = array
+                               (
+                                       'total_records'         => 
$this->db->f('cnt'),
+                                       'sum_budget'            => 
$this->db->f('sum_budget'),
+                                       'sum_actual_cost'       => 
$this->db->f('sum_actual_cost'),
+                                       'sql_hash'                      => 
md5($sql_cnt)
+                               );
+                               
phpgwapi_cache::session_set('property','tts_listing_metadata',$cache_info);
+                       }
+
+                       $this->total_records    = $cache_info['total_records'];
+                       $this->sum_budget               = 
$cache_info['sum_budget'];
+                       $this->sum_actual_cost  = 
$cache_info['sum_actual_cost'];
+
                        $tickets = array();
                        if(!$dry_run)
                        {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]