BUG-13421 Ordenamiento en el listado de procesos 'Designer'.

Se agregaron validaciones en los files: workflow/engine/classes/model/Process.php y workflow/engine/methods/processes/processesList.php para que se realize el ordenamiento ASC y DESC tomando en cuenta si se encuentra o no habilitado el uso de 'memcache' para listar de una forma mas veloz todos los procesos.
This commit is contained in:
jennylee
2013-11-06 13:34:25 -04:00
parent 8db121068d
commit 756a126a1c
3 changed files with 44 additions and 25 deletions

View File

@@ -387,7 +387,7 @@ class Process extends BaseProcess
} }
} }
usort( $processes, 'ordProcessByProTitle' ); usort( $processes, 'ordProcess' );
return $processes; return $processes;
} }
@@ -589,7 +589,7 @@ class Process extends BaseProcess
public function getAllProcesses ($start, $limit, $category = null, $processName = null, $counters = true, $reviewSubProcess = false) public function getAllProcesses ($start, $limit, $category = null, $processName = null, $counters = true, $reviewSubProcess = false)
{ {
require_once PATH_RBAC . "model/RbacUsers.php"; require_once PATH_RBAC . "model/RbacUsers.php";
require_once "classes/model/ProcessCategory.php"; require_once "classes/model/ProcessCategory.php";
require_once "classes/model/Users.php"; require_once "classes/model/Users.php";
@@ -629,14 +629,7 @@ class Process extends BaseProcess
$this->tmpCriteria = clone $oCriteria; $this->tmpCriteria = clone $oCriteria;
if ($start != '') { //execute a query to obtain numbers, how many cases there are by process
$oCriteria->setOffset( $start );
}
if ($limit != '' && ! isset( $category ) && ! isset( $processName )) {
$oCriteria->setLimit( $limit );
}
//execute a query to obtain numbers, how many cases there are by process
if ($counters) { if ($counters) {
$casesCnt = $this->getCasesCountInAllProcesses(); $casesCnt = $this->getCasesCountInAllProcesses();
} }
@@ -741,8 +734,13 @@ class Process extends BaseProcess
$aProcesses[] = $process; $aProcesses[] = $process;
} }
usort( $aProcesses, 'ordProcessByProTitle' ); $memcache = & PMmemcached::getSingleton( SYS_SYS );
if ($memcache->enabled == 0) {
usort( $aProcesses, 'ordProcess' );
$aProcesses = array_splice($aProcesses, $start, $limit);
}
return $aProcesses; return $aProcesses;
} }
@@ -848,16 +846,35 @@ class Process extends BaseProcess
$r = $memcache->delete( $memkeyTotal ); $r = $memcache->delete( $memkeyTotal );
} }
} }
}
public function orderMemcache($dataMemcache, $start, $limit)
function ordProcessByProTitle ($a, $b) {
{ usort( $dataMemcache, 'ordProcess' );
if ($a['PRO_TITLE'] > $b['PRO_TITLE']) { $dataMemcache = array_splice($dataMemcache, $start, $limit);
return 1; return $dataMemcache;
} elseif ($a['PRO_TITLE'] < $b['PRO_TITLE']) { }
return - 1; }
} else {
return 0; function ordProcess ($a, $b)
{
if (isset($_POST['sort'])) {
if ($_POST['dir']=='ASC') {
if ($a[$_POST['sort']] > $b[$_POST['sort']]) {
return 1;
} elseif ($a[$_POST['sort']] < $b[$_POST['sort']]) {
return - 1;
} else {
return 0;
}
} else {
if ($a[$_POST['sort']] > $b[$_POST['sort']]) {
return - 1;
} elseif ($a[$_POST['sort']] < $b[$_POST['sort']]) {
return 1;
} else {
return 0;
}
}
} }
} }

View File

@@ -34,7 +34,6 @@ $oProcess = new Process();
$memkey = 'no memcache'; $memkey = 'no memcache';
$memcacheUsed = 'not used'; $memcacheUsed = 'not used';
$totalCount = 0; $totalCount = 0;
if (isset( $_POST['category'] ) && $_POST['category'] !== '<reset>') { if (isset( $_POST['category'] ) && $_POST['category'] !== '<reset>') {
if (isset( $_POST['processName'] )) if (isset( $_POST['processName'] ))
$proData = $oProcess->getAllProcesses( $start, $limit, $_POST['category'], $_POST['processName'] ); $proData = $oProcess->getAllProcesses( $start, $limit, $_POST['category'], $_POST['processName'] );
@@ -54,12 +53,14 @@ if (isset( $_POST['category'] ) && $_POST['category'] !== '<reset>') {
$memkeyTotal = $memkey . '-total'; $memkeyTotal = $memkey . '-total';
$memcacheUsed = 'yes'; $memcacheUsed = 'yes';
if (($proData = $memcache->get( $memkey )) === false || ($totalCount = $memcache->get( $memkeyTotal )) === false) { if (($proData = $memcache->get( $memkey )) === false || ($totalCount = $memcache->get( $memkeyTotal )) === false) {
$proData = $oProcess->getAllProcesses( $start, $limit ); $proData = $oProcess->getAllProcesses( $start, $limit );
$totalCount = $oProcess->getAllProcessesCount(); $totalCount = $oProcess->getAllProcessesCount();
$memcache->set( $memkey, $proData, PMmemcached::ONE_HOUR ); $memcache->set( $memkey, $proData, PMmemcached::ONE_HOUR );
$memcache->set( $memkeyTotal, $totalCount, PMmemcached::ONE_HOUR ); $memcache->set( $memkeyTotal, $totalCount, PMmemcached::ONE_HOUR );
$memcacheUsed = 'no'; $memcacheUsed = 'no';
} } else {
$proData = $oProcess->orderMemcache($proData, $start, $limit);
}
} }
} }
$r = new stdclass(); $r = new stdclass();

View File

@@ -37,6 +37,7 @@ Ext.onReady(function(){
store = new Ext.data.GroupingStore( { store = new Ext.data.GroupingStore( {
//var store = new Ext.data.Store( { //var store = new Ext.data.Store( {
remoteSort: true,
proxy : new Ext.data.HttpProxy({ proxy : new Ext.data.HttpProxy({
url: 'processesList' url: 'processesList'
}), }),