From fa3dec263f66bd6995d791aaaf4add4240266825 Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Tue, 15 Feb 2022 22:26:10 +0100 Subject: [PATCH] performance optimizations --- application/Building/BuildingModel.php | 8 +++-- application/Linework/LineworkController.php | 8 +++-- application/Pop/PopModel.php | 8 +++-- application/Termination/Termination.php | 8 +++++ .../Termination/TerminationController.php | 8 +++-- application/Termination/TerminationModel.php | 8 +++-- .../TerminationFile/TerminationFileModel.php | 8 +++-- .../Workflowitem/WorkflowitemModel.php | 8 +++-- application/Workflowvalue/Workflowvalue.php | 33 +++++++++++++++---- .../Workflowvalue/WorkflowvalueModel.php | 8 +++-- 10 files changed, 82 insertions(+), 23 deletions(-) diff --git a/application/Building/BuildingModel.php b/application/Building/BuildingModel.php index 8b6d975f6..fa97fb162 100644 --- a/application/Building/BuildingModel.php +++ b/application/Building/BuildingModel.php @@ -37,8 +37,12 @@ class BuildingModel { } } - $me = new User(); - $me->loadMe(); + $me = mfValuecache::get("me"); + if(!$me) { + $me = new User(); + $me->loadMe(); + mfValuecache::set("me", $this->me); + } if($model->create_by === null) { $model->create_by = $me->id; diff --git a/application/Linework/LineworkController.php b/application/Linework/LineworkController.php index 30d404507..7bee13a27 100644 --- a/application/Linework/LineworkController.php +++ b/application/Linework/LineworkController.php @@ -4,8 +4,12 @@ class LineworkController extends mfBaseController { protected function init() { $this->needlogin=true; - $me = new User(); - $me->loadMe(); + $me = mfValuecache::get("me"); + if(!$me) { + $me = new User(); + $me->loadMe(); + mfValuecache::set("me", $this->me); + } $this->me = $me; $this->layout()->set("me",$me); diff --git a/application/Pop/PopModel.php b/application/Pop/PopModel.php index 4d4166cd1..c53aedbc6 100644 --- a/application/Pop/PopModel.php +++ b/application/Pop/PopModel.php @@ -34,8 +34,12 @@ class PopModel { } } - $me = new User(); - $me->loadMe(); + $me = mfValuecache::get("me"); + if(!$me) { + $me = new User(); + $me->loadMe(); + mfValuecache::set("me", $this->me); + } if($model->create_by === null) { $model->create_by = $me->id; diff --git a/application/Termination/Termination.php b/application/Termination/Termination.php index 5a394d659..c080caf76 100644 --- a/application/Termination/Termination.php +++ b/application/Termination/Termination.php @@ -282,7 +282,15 @@ class Termination extends mfBaseModel { } if($name == "creator") { + $user = mfValuecache::get("Worker-id-".$this->create_by); + if($user) { + $this->creator = $user; + return $this->creator; + } $this->creator = new User($this->create_by); + if($this->creator->id) { + mfValuecache::set("Worker-id-".$this->create_by, $this->creator); + } return $this->creator; } diff --git a/application/Termination/TerminationController.php b/application/Termination/TerminationController.php index 750dbf188..5b74be8c6 100644 --- a/application/Termination/TerminationController.php +++ b/application/Termination/TerminationController.php @@ -4,8 +4,12 @@ class TerminationController extends mfBaseController { protected function init() { $this->needlogin=true; - $me = new User(); - $me->loadMe(); + $me = mfValuecache::get("me"); + if(!$me) { + $me = new User(); + $me->loadMe(); + mfValuecache::set("me", $this->me); + } $this->me = $me; $this->layout()->set("me",$me); diff --git a/application/Termination/TerminationModel.php b/application/Termination/TerminationModel.php index 9007a2e7d..7f63fb9f8 100644 --- a/application/Termination/TerminationModel.php +++ b/application/Termination/TerminationModel.php @@ -30,8 +30,12 @@ class TerminationModel { $model->status_id = 1; } - $me = new User(); - $me->loadMe(); + $me = mfValuecache::get("me"); + if(!$me) { + $me = new User(); + $me->loadMe(); + mfValuecache::set("me", $this->me); + } if($model->create_by === null) { $model->create_by = $me->id; diff --git a/application/TerminationFile/TerminationFileModel.php b/application/TerminationFile/TerminationFileModel.php index f8ed330f1..bb2871f12 100644 --- a/application/TerminationFile/TerminationFileModel.php +++ b/application/TerminationFile/TerminationFileModel.php @@ -21,8 +21,12 @@ class TerminationFileModel { } } - $me = new User(); - $me->loadMe(); + $me = mfValuecache::get("me"); + if(!$me) { + $me = new User(); + $me->loadMe(); + mfValuecache::set("me", $this->me); + } if($model->create_by === null) { $model->create_by = $me->id; diff --git a/application/Workflowitem/WorkflowitemModel.php b/application/Workflowitem/WorkflowitemModel.php index 1b540d213..b52ff1a03 100644 --- a/application/Workflowitem/WorkflowitemModel.php +++ b/application/Workflowitem/WorkflowitemModel.php @@ -27,8 +27,12 @@ class WorkflowitemModel { } } - $me = new User(); - $me->loadMe(); + $me = mfValuecache::get("me"); + if(!$me) { + $me = new User(); + $me->loadMe(); + mfValuecache::set("me", $this->me); + } if($model->create_by === null) { $model->create_by = $me->id; diff --git a/application/Workflowvalue/Workflowvalue.php b/application/Workflowvalue/Workflowvalue.php index 72e2da344..0c5b96be7 100644 --- a/application/Workflowvalue/Workflowvalue.php +++ b/application/Workflowvalue/Workflowvalue.php @@ -3,10 +3,23 @@ class Workflowvalue extends mfBaseModel { private $item; private $changer; + private $me; + public $gps = []; + public $is_changed = false; + protected function init() { + $this->me = mfValuecache::get("me"); + if(!$this->me) { + $this->me = new User(); + $this->me->loadMe(); + mfValuecache::set("me", $this->me); + } + + } + protected function afterLoad() { if(!$this->id) { return true; @@ -19,10 +32,8 @@ class Workflowvalue extends mfBaseModel { protected function beforeSave() { if($this->new() == "new") { - $me = new User(); - $me->loadMe(); $this->changed = date('U'); - $this->changed_by = $me->id; + $this->changed_by = $this->me->id; } } @@ -102,18 +113,18 @@ class Workflowvalue extends mfBaseModel { $this->is_changed = true; - $me = new User(); - $me->loadMe(); + /*$me = new User(); + $me->loadMe();*/ if($this->{"value_".$value_type} != $value) { $this->{"value_".$value_type} = $value; $this->changed = date('U'); - $this->changed_by = $me->id; + $this->changed_by = $this->me->id; } /*if($this->new() == "new") { $this->changed = date('U'); - $this->changed_by = $me->id; + $this->changed_by = $this->me->id; }*/ } @@ -127,8 +138,16 @@ class Workflowvalue extends mfBaseModel { } if($name == "changer") { + $user = mfValuecache::get("Worker-id-".$this->changed); + if($user) { + $this->changer = $user; + return $this->changer; + } if($this->changed && $this->changed_by) { $this->changer = new User($this->changed_by); + if($this->changer->id) { + mfValuecache::set("Worker-id-".$this->changed, $this->changer); + } return $this->changer; } else { return new Address(); diff --git a/application/Workflowvalue/WorkflowvalueModel.php b/application/Workflowvalue/WorkflowvalueModel.php index 254bbb951..2fd531028 100644 --- a/application/Workflowvalue/WorkflowvalueModel.php +++ b/application/Workflowvalue/WorkflowvalueModel.php @@ -24,8 +24,12 @@ class WorkflowvalueModel { } } - $me = new User(); - $me->loadMe(); + $me = mfValuecache::get("me"); + if(!$me) { + $me = new User(); + $me->loadMe(); + mfValuecache::set("me", $this->me); + } if($model->create_by === null) { $model->create_by = $me->id;