performance optimization
This commit is contained in:
@@ -80,21 +80,53 @@ class Building extends mfBaseModel {
|
||||
}
|
||||
|
||||
public function loadWorkflowItems() {
|
||||
foreach(WorkflowitemModel::search(["object_type" => "building", "active" => 1]) as $item) {
|
||||
/*foreach(WorkflowitemModel::search(["object_type" => "building", "active" => 1]) as $item) {
|
||||
$item->setObjectId($this->id);
|
||||
$this->workflowitems[$item->name] = $item;
|
||||
mfValuecache::singleton()->set("wfBuilding-".$item->name, $item);
|
||||
}*/
|
||||
|
||||
|
||||
$item_ids = [];
|
||||
|
||||
$building_wfitems = mfValuecache::singleton()->get("wfitems-building-active");
|
||||
if(!$building_wfitems) {
|
||||
$building_wfitems = WorkflowitemModel::search(["object_type" => "building", "active" => 1]);
|
||||
mfValuecache::singleton()->set("wfitems-building-active", $building_wfitems);
|
||||
}
|
||||
|
||||
foreach($building_wfitems as $item) {
|
||||
$item->setObjectId($this->id);
|
||||
$this->workflowitems[$item->name] = $item;
|
||||
mfValuecache::singleton()->set("wfBuilding-name-".$item->name, $item);
|
||||
mfValuecache::singleton()->set("wfBuilding-id-".$item->id, $item);
|
||||
$item_ids[] = $item->id;
|
||||
}
|
||||
|
||||
foreach($item_ids as $id) {
|
||||
mfValuecache::singleton()->set("wfItemvalue-item-".$id."-object-".$this->id, new Workflowvalue());
|
||||
}
|
||||
|
||||
// get values
|
||||
$values = WorkflowvalueModel::search(["object_id" => $this->id]);
|
||||
//var_dump($values);exit;
|
||||
foreach($values as $value) {
|
||||
if(array_key_exists($value->item->name, $this->workflowitems)) {
|
||||
//var_dump($value);exit;
|
||||
$this->workflowitems[$value->item->name]->setValue($value);
|
||||
mfValuecache::singleton()->set("wfItemvalue-item-".$value->item_id."-object-".$this->id, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getWorkflowvalue($itemname, $type = false) {
|
||||
$item = mfValuecache::singleton()->get("wfBuilding-".$itemname);
|
||||
$item = mfValuecache::singleton()->get("wfBuilding-name-".$itemname);
|
||||
if(!$item) {
|
||||
$item = WorkflowitemModel::getFirst(['name' => $itemname]);
|
||||
if(!$item->id) {
|
||||
return null;
|
||||
}
|
||||
mfValuecache::singleton()->set("wfBuilding-".$itemname, $item);
|
||||
mfValuecache::singleton()->set("wfBuilding-name-".$itemname, $item);
|
||||
}
|
||||
|
||||
switch($item->type) {
|
||||
|
||||
Reference in New Issue
Block a user