performance optimizations

This commit is contained in:
Frank Schubert
2022-02-15 22:26:10 +01:00
parent dd6f171ee1
commit fa3dec263f
10 changed files with 82 additions and 23 deletions

View File

@@ -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();