Add caching for network sections and add indexes for order tables
This commit is contained in:
@@ -125,7 +125,12 @@ class Network extends mfBaseModel {
|
||||
}
|
||||
|
||||
if($name == "sections") {
|
||||
$this->sections = NetworksectionModel::search(['network_id' => $this->id]);
|
||||
$cache_key = "network_".$this->id."_sections";
|
||||
$this->sections = mfValuecache::singleton()->get($cache_key);
|
||||
if($this->sections === NULL) {
|
||||
$this->sections = NetworksectionModel::search(['network_id' => $this->id]);
|
||||
mfValuecache::singleton()->set($cache_key, $this->sections);
|
||||
}
|
||||
return $this->sections;
|
||||
}
|
||||
|
||||
|
||||
46
db/migrations/20240207155725_add_indexes_for_order.php
Normal file
46
db/migrations/20240207155725_add_indexes_for_order.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class AddIndexesForOrder extends AbstractMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if ($this->getEnvironment() == "thetool") {
|
||||
$this->execute("ALTER TABLE `ProducttechAttribute` ADD INDEX `producttech_id` (`producttech_id`)");
|
||||
$this->execute("ALTER TABLE `Worker` ADD INDEX `username` (`username`)");
|
||||
$this->execute("ALTER TABLE `OrderProduct` ADD INDEX `order_id` (`order_id`)");
|
||||
$this->execute("ALTER TABLE `Patching` ADD INDEX `termination_id` (`termination_id`)");
|
||||
$this->execute("ALTER TABLE `OrderJournal` ADD INDEX `order_id` (`order_id`)");
|
||||
$this->execute("ALTER TABLE `OrderFile` ADD INDEX `file_id` (`file_id`)");
|
||||
$this->execute("ALTER TABLE `OrderFile` ADD INDEX `order_id` (`order_id`)");
|
||||
$this->execute("ALTER TABLE `Networksection` ADD INDEX `network_id` (`network_id`)");
|
||||
$this->execute("ALTER TABLE `WorkerPermission` ADD INDEX `worker_id` (`worker_id`)");
|
||||
$this->execute("ALTER TABLE `WorkerFlag` ADD INDEX `network_id` (`worker_id`)");
|
||||
}
|
||||
|
||||
if ($this->getEnvironment() == "addressdb") {
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if ($this->getEnvironment() == "thetool") {
|
||||
$this->execute("ALTER TABLE `ProducttechAttribute` DROP INDEX `producttech_id`");
|
||||
$this->execute("ALTER TABLE `Worker` DROP INDEX `username`");
|
||||
$this->execute("ALTER TABLE `OrderProduct` DROP INDEX `order_id`");
|
||||
$this->execute("ALTER TABLE `Patching` DROP INDEX `termination_id`");
|
||||
$this->execute("ALTER TABLE `OrderJournal` DROP INDEX `order_id`");
|
||||
$this->execute("ALTER TABLE `OrderFile` DROP INDEX `file_id`");
|
||||
$this->execute("ALTER TABLE `OrderFile` DROP INDEX `order_id`");
|
||||
$this->execute("ALTER TABLE `Networksection` DROP INDEX `network_id`");
|
||||
$this->execute("ALTER TABLE `WorkerPermission` DROP INDEX `worker_id`");
|
||||
$this->execute("ALTER TABLE `WorkerFlag` DROP INDEX `worker_id`");
|
||||
}
|
||||
|
||||
if ($this->getEnvironment() == "addressdb") {
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user