performance optimizations

This commit is contained in:
Frank Schubert
2022-02-15 23:12:19 +01:00
parent fa3dec263f
commit c189041b67
10 changed files with 72 additions and 36 deletions
+5 -5
View File
@@ -154,11 +154,11 @@
<?php if($bcount > 0): ?> <?php if($bcount > 0): ?>
<tr id="termination-<?=$term->id?>-top-header" class="hidden"> <tr id="termination-<?=$term->id?>-top-header" class="hidden">
<th>Anschluss</th> <th>Anschluss</th>
<th>Baustatus</th> <th>Tiefbau</th>
<th>Patchstatus</th> <th>Patch-/Kabeldaten</th>
<th>BB hergestellt</th> <th>Backbone</th>
<th>BEP montiert</th> <th>BEP</th>
<th>K-Kabel eingeblasen</th> <th>Kundenkabel</th>
<th>Spleiß Netz</th> <th>Spleiß Netz</th>
<th>Spleiß Kunde</th> <th>Spleiß Kunde</th>
<th>Fertig</th> <th>Fertig</th>
+3 -3
View File
@@ -83,18 +83,18 @@ class Building extends mfBaseModel {
foreach(WorkflowitemModel::search(["object_type" => "building", "active" => 1]) as $item) { foreach(WorkflowitemModel::search(["object_type" => "building", "active" => 1]) as $item) {
$item->setObjectId($this->id); $item->setObjectId($this->id);
$this->workflowitems[$item->name] = $item; $this->workflowitems[$item->name] = $item;
mfValuecache::set("wfBuilding-".$item->name, $item); mfValuecache::singleton()->set("wfBuilding-".$item->name, $item);
} }
} }
public function getWorkflowvalue($itemname, $type = false) { public function getWorkflowvalue($itemname, $type = false) {
$item = mfValuecache::get("wfBuilding-".$itemname); $item = mfValuecache::singleton()->get("wfBuilding-".$itemname);
if(!$item) { if(!$item) {
$item = WorkflowitemModel::getFirst(['name' => $itemname]); $item = WorkflowitemModel::getFirst(['name' => $itemname]);
if(!$item->id) { if(!$item->id) {
return null; return null;
} }
mfValuecache::set("wfBuilding-".$itemname, $item); mfValuecache::singleton()->set("wfBuilding-".$itemname, $item);
} }
switch($item->type) { switch($item->type) {
+2 -2
View File
@@ -4,11 +4,11 @@ class LineworkController extends mfBaseController {
protected function init() { protected function init() {
$this->needlogin=true; $this->needlogin=true;
$me = mfValuecache::get("me"); $me = mfValuecache::singleton()->get("me");
if(!$me) { if(!$me) {
$me = new User(); $me = new User();
$me->loadMe(); $me->loadMe();
mfValuecache::set("me", $this->me); mfValuecache::singleton()->set("me", $this->me);
} }
$this->me = $me; $this->me = $me;
$this->layout()->set("me",$me); $this->layout()->set("me",$me);
+25 -5
View File
@@ -36,21 +36,41 @@ class Termination extends mfBaseModel {
} }
public function loadWorkflowItems() { public function loadWorkflowItems() {
$item_ids = [];
foreach(WorkflowitemModel::search(["object_type" => "Termination", "active" => 1]) as $item) { foreach(WorkflowitemModel::search(["object_type" => "Termination", "active" => 1]) as $item) {
$item->setObjectId($this->id); $item->setObjectId($this->id);
$this->workflowitems[$item->name] = $item; $this->workflowitems[$item->name] = $item;
mfValuecache::set("wfTerm-".$item->name, $item); //mfValuecache::set("wfTerm-name-".$item->name, $item);
//mfValuecache::set("wfTerm-id-".$item->id, $item);
$item_ids[] = $item->id;
} }
// 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("wfTerm-name-".$this->workflowitems[$value->item->name]->name, $this->workflowitems[$value->item->name]);
mfValuecache::singleton()->set("wfTerm-id-".$this->workflowitems[$value->item->name]->id, $this->workflowitems[$value->item->name]);
mfValuecache::singleton()->set("wfItemvalue-item-".$value->item_id."-object-".$value->object_id, $value);
}
}
//var_dump(array_keys(mfValuecache::singleton()->getCache()));
} }
public function getWorkflowvalue($itemname, $type = false) { public function getWorkflowvalue($itemname, $type = false) {
$item = mfValuecache::get("wfTerm-".$itemname); $item = mfValuecache::singleton()->get("wfTerm-name-".$itemname);
if(!$item) { if(!$item) {
$item = WorkflowitemModel::getFirst(['name' => $itemname]); $item = WorkflowitemModel::getFirst(['name' => $itemname]);
if(!$item->id) { if(!$item->id) {
return null; return null;
} }
mfValuecache::set("wfTerm-".$itemname, $item); mfValuecache::singleton()->set("wfTerm-name-".$itemname, $item);
mfValuecache::singleton()->set("wfTerm-id-".$item->id, $item);
} }
switch($item->type) { switch($item->type) {
@@ -282,14 +302,14 @@ class Termination extends mfBaseModel {
} }
if($name == "creator") { if($name == "creator") {
$user = mfValuecache::get("Worker-id-".$this->create_by); $user = mfValuecache::singleton()->get("Worker-id-".$this->create_by);
if($user) { if($user) {
$this->creator = $user; $this->creator = $user;
return $this->creator; return $this->creator;
} }
$this->creator = new User($this->create_by); $this->creator = new User($this->create_by);
if($this->creator->id) { if($this->creator->id) {
mfValuecache::set("Worker-id-".$this->create_by, $this->creator); mfValuecache::singleton()->set("Worker-id-".$this->create_by, $this->creator);
} }
return $this->creator; return $this->creator;
} }
+10
View File
@@ -12,6 +12,10 @@ class Workflowitem extends mfBaseModel {
return true; return true;
} }
public function setValue(Workflowvalue $value) {
$this->value = $value;
}
public function getProperty($name) { public function getProperty($name) {
if($this->$name == null) { if($this->$name == null) {
@@ -20,12 +24,18 @@ class Workflowitem extends mfBaseModel {
$this->log->warn(__CLASS__."::getProperty('value'): Object ID not set"); $this->log->warn(__CLASS__."::getProperty('value'): Object ID not set");
return null; return null;
} }
$value = mfValuecache::singleton()->get("wfItemvalue-item-".$this->id."-object-".$this->object_id);
if($value) {
$this->value = $value;
return $value;
}
$value = WorkflowvalueModel::getFirst(['item_id' => $this->id, "object_id" => $this->object_id]); $value = WorkflowvalueModel::getFirst(['item_id' => $this->id, "object_id" => $this->object_id]);
if(!$value) { if(!$value) {
$vdata['item_id'] = $this->id; $vdata['item_id'] = $this->id;
$vdata['object_id'] = $this->object_id; $vdata['object_id'] = $this->object_id;
$value = WorkflowvalueModel::create($vdata); $value = WorkflowvalueModel::create($vdata);
} }
mfValuecache::singleton()->set("wfItemvalue-item-".$this->id."-object-".$this->object_id, $value);
$this->value = $value; $this->value = $value;
return $this->value; return $this->value;
} }
@@ -27,11 +27,11 @@ class WorkflowitemModel {
} }
} }
$me = mfValuecache::get("me"); $me = mfValuecache::singleton()->get("me");
if(!$me) { if(!$me) {
$me = new User(); $me = new User();
$me->loadMe(); $me->loadMe();
mfValuecache::set("me", $this->me); mfValuecache::singleton()->set("me", $this->me);
} }
if($model->create_by === null) { if($model->create_by === null) {
+12 -5
View File
@@ -11,11 +11,11 @@ class Workflowvalue extends mfBaseModel {
public $is_changed = false; public $is_changed = false;
protected function init() { protected function init() {
$this->me = mfValuecache::get("me"); $this->me = mfValuecache::singleton()->get("me");
if(!$this->me) { if(!$this->me) {
$this->me = new User(); $this->me = new User();
$this->me->loadMe(); $this->me->loadMe();
mfValuecache::set("me", $this->me); mfValuecache::singleton()->set("me", $this->me);
} }
} }
@@ -133,12 +133,19 @@ class Workflowvalue extends mfBaseModel {
if($this->$name == null) { if($this->$name == null) {
if($name == "item") { if($name == "item") {
$this->item = new Workflowitem($this->item_id); $this->item = mfValuecache::singleton()->get("wfItem-id-".$this->item_id);
if(!$this->item) {
$this->item = new Workflowitem($this->item_id);
if($this->item->id) {
mfValuecache::singleton()->set("wfItem-id-".$this->item->id, $this->item);
}
}
return $this->item; return $this->item;
} }
if($name == "changer") { if($name == "changer") {
$user = mfValuecache::get("Worker-id-".$this->changed); $user = mfValuecache::singleton()->get("Worker-id-".$this->changed);
if($user) { if($user) {
$this->changer = $user; $this->changer = $user;
return $this->changer; return $this->changer;
@@ -146,7 +153,7 @@ class Workflowvalue extends mfBaseModel {
if($this->changed && $this->changed_by) { if($this->changed && $this->changed_by) {
$this->changer = new User($this->changed_by); $this->changer = new User($this->changed_by);
if($this->changer->id) { if($this->changer->id) {
mfValuecache::set("Worker-id-".$this->changed, $this->changer); mfValuecache::singleton()->set("Worker-id-".$this->changed, $this->changer);
} }
return $this->changer; return $this->changer;
} else { } else {
@@ -24,11 +24,11 @@ class WorkflowvalueModel {
} }
} }
$me = mfValuecache::get("me"); $me = mfValuecache::singleton()->get("me");
if(!$me) { if(!$me) {
$me = new User(); $me = new User();
$me->loadMe(); $me->loadMe();
mfValuecache::set("me", $this->me); mfValuecache::singleton()->set("me", $this->me);
} }
if($model->create_by === null) { if($model->create_by === null) {
+10 -11
View File
@@ -4,10 +4,7 @@ class mfValuecache {
public static $instance; public static $instance;
public $cache = []; public $cache = [];
private function __construct() { }
private function __construct() {
}
public static function singleton() { public static function singleton() {
if(!isset(self::$instance)) { if(!isset(self::$instance)) {
@@ -17,16 +14,18 @@ class mfValuecache {
return self::$instance; return self::$instance;
} }
public static function get($key) { public function get($key) {
$instance = self::singleton(); if(array_key_exists($key, $this->cache)) {
if(array_key_exists($key, $instance->cache)) { return $this->cache[$key];
return $instance->cache[$key];
} }
return null; return null;
} }
public static function set($key, $value) { public function set($key, $value) {
$instance = self::singleton(); $this->cache[$key] = $value;
$instance->cache[$key] = $value; }
public function getCache() {
return $this->cache;
} }
} }
+1 -1
View File
@@ -21,7 +21,7 @@ if(defined('MFLOCALE_NUMERIC')) {
setlocale(LC_NUMERIC, MFLOCALE_NUMERIC); setlocale(LC_NUMERIC, MFLOCALE_NUMERIC);
} }
define('FRONKDB_SQLDEBUG',false); define('FRONKDB_SQLDEBUG',true);
error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED)); error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED));
require_once(LIBDIR."/mvcfronk/mfRouter/mfRouter.php"); require_once(LIBDIR."/mvcfronk/mfRouter/mfRouter.php");