Author: david
Date: Mon Oct 19 14:01:45 2009
New Revision: 3769
Log:
Add QubitInformationObject::hasChildren() method as a quick way to find out if
an information object has children, which doesn't require an additional db
query. Implement in treeview - reduces page load time by approx. 6 seconds for
300 objects. See issue #1068.
Modified:
trunk/apps/qubit/modules/informationobject/actions/treeViewComponent.class.php
trunk/lib/model/QubitInformationObject.php
Modified:
trunk/apps/qubit/modules/informationobject/actions/treeViewComponent.class.php
==============================================================================
---
trunk/apps/qubit/modules/informationobject/actions/treeViewComponent.class.php
Mon Oct 19 13:25:14 2009 (r3768)
+++
trunk/apps/qubit/modules/informationobject/actions/treeViewComponent.class.php
Mon Oct 19 14:01:45 2009 (r3769)
@@ -45,7 +45,7 @@
$treeViewObject['href'] =
$this->getController()->genUrl('informationobject/show?id='.$informationObject->getId());
$treeViewObject['id'] = $informationObject->getId();
$treeViewObject['parentId'] = $informationObject->getParentId();
- $treeViewObject['isLeaf'] = (string)
count($informationObject->getDescendants()) == 0;
+ $treeViewObject['isLeaf'] = (string) !$informationObject->hasChildren();
// TODO: Should be able to check equality of objects
if ($informationObject->getId() == $this->informationObject->getId())
Modified: trunk/lib/model/QubitInformationObject.php
==============================================================================
--- trunk/lib/model/QubitInformationObject.php Mon Oct 19 13:25:14 2009
(r3768)
+++ trunk/lib/model/QubitInformationObject.php Mon Oct 19 14:01:45 2009
(r3769)
@@ -1612,4 +1612,15 @@
}
}
}
+
+ /**
+ * Speed-optimized method for checking if information object has children
+ * which doesn't require hitting database.
+ *
+ * @return boolean - true if has children
+ */
+ public function hasChildren()
+ {
+ return ($this->rgt - $this->lft) > 1;
+ }
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.ca/group/qubit-commits?hl=en
-~----------~----~----~----~------~----~------~--~---