Quellcode durchsuchen

[Administration] Distributions : optimisation du chargement des jours de distribution

feature/rotating_product
Guillaume Bourgeois vor 6 Monaten
Ursprung
Commit
d189dfe1d1
5 geänderte Dateien mit 56 neuen und 12 gelöschten Zeilen
  1. +11
    -9
      backend/controllers/DistributionController.php
  2. +41
    -0
      console/migrations/m240508_093106_create_indexes_performance.php
  3. +1
    -0
      domain/Product/Product/Product.php
  4. +2
    -2
      domain/User/User/User.php
  5. +1
    -1
      domain/User/UserProducer/UserProducerRepository.php

+ 11
- 9
backend/controllers/DistributionController.php Datei anzeigen

@@ -318,6 +318,8 @@ class DistributionController extends BackendController
$productOrderModule = $this->getProductOrderModule();
$userProducerModule = $this->getUserProducerModule();



if ($ordersArray) {
foreach ($ordersArray as &$order) {

@@ -395,15 +397,15 @@ class DistributionController extends BackendController
'productOrder' => $productOrderArray,
'paymentsArray' => $paymentArray,
'oneProductUnactivated' => $oneProductUnactivated,
'isLinkedToValidDocument' => $orderModule->isLinkedToValidDocument($order),
'isLinkedToValidInvoice' => $orderModule->isLinkedToValidInvoice($order),
'isCreditAutoPayment' => $orderModule->isCreditAutoPayment($order),
'isCreditContext' => $orderModule->isCreditContext($order),
'isPaid' => $orderModule->isOrderPaid($order),
'isPaidViaInvoice' => $orderModule->isOrderPaidViaInvoice($order),
'paymentLabelShort' => $orderModule->getPaymentLabelShort($order),
'isCreditFunctioningMandatory' => $orderModule->isOrderCreditFunctioningMandatory($order),
'isCreditFunctioningUser' => $orderModule->isOrderCreditFunctioningUser($order),
'isLinkedToValidDocument' => $orderModule->getSolver()->isLinkedToValidDocument($order),
'isLinkedToValidInvoice' => $orderModule->getSolver()->isLinkedToValidInvoice($order),
'isCreditAutoPayment' => $orderModule->getRepository()->isCreditAutoPayment($order),
'isCreditContext' => $orderModule->getRepository()->isCreditContext($order),
'isPaid' => $orderModule->getRepository()->isOrderPaid($order),
'isPaidViaInvoice' => $orderModule->getRepository()->isOrderPaidViaInvoice($order),
'paymentLabelShort' => $orderModule->getRepository()->getPaymentLabelShort($order),
'isCreditFunctioningMandatory' => $orderModule->getRepository()->isOrderCreditFunctioningMandatory($order),
'isCreditFunctioningUser' => $orderModule->getRepository()->isOrderCreditFunctioningUser($order),
'debitCredit' => false,
'deliveryNote' => $order->deliveryNote ? $order->deliveryNote->getAttributes() : null
]);

+ 41
- 0
console/migrations/m240508_093106_create_indexes_performance.php Datei anzeigen

@@ -0,0 +1,41 @@
<?php

use yii\db\Migration;

/**
* Class m240508_093106_create_indexes_performance
*/
class m240508_093106_create_indexes_performance extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->createIndex('id_user', 'user_producer', 'id_user');
$this->createIndex('id_producer', 'user_producer', 'id_producer');
$this->createIndex('id_product', 'product_price', 'id_product');
$this->createIndex('status', 'user', 'status');
$this->createIndex('email', 'user', 'email');
$this->createIndex('type', 'user', 'type');
$this->createIndex('id_producer', 'user', 'id_producer');
$this->createIndex('date', 'distribution', 'date');
$this->createIndex('id_producer', 'distribution', 'id_producer');
}

/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropIndex('id_user', 'user_producer');
$this->dropIndex('id_producer', 'user_producer');
$this->dropIndex('id_product', 'product_prices');
$this->dropIndex('status', 'user');
$this->dropIndex('email', 'user');
$this->dropIndex('type', 'user');
$this->dropIndex('id_producer', 'user');
$this->dropIndex('date', 'distribution');
$this->dropIndex('id_producer', 'distribution');
}
}

+ 1
- 0
domain/Product/Product/Product.php Datei anzeigen

@@ -181,6 +181,7 @@ class Product extends ActiveRecordCommon implements StatusInterface

public function afterFind()
{
// @TODO : à optimiser
if ($this->taxRate == null) {
if(GlobalParam::getCurrentProducerId() && $this->id_producer == GlobalParam::getCurrentProducerId()) {
$producer = GlobalParam::getCurrentProducer();

+ 2
- 2
domain/User/User/User.php Datei anzeigen

@@ -223,9 +223,9 @@ class User extends ActiveRecordCommon implements IdentityInterface
public function verifyEmail($attribute, $params)
{
if ($this->id) {
$user = User::find()->where("email LIKE :email AND type != :guest AND id != :id")->params(array(':email' => '%' . $this->email . '%', ':id' => $this->id, ':guest' => 'guest'))->one();
$user = User::find()->where("email LIKE :email AND type != :guest AND id != :id")->params(array(':email' => $this->email, ':id' => $this->id, ':guest' => 'guest'))->one();
} else {
$user = User::find()->where("email LIKE :email AND type != :guest")->params(array(':email' => '%' . $this->email . '%', ':guest' => 'guest'))->one();
$user = User::find()->where("email LIKE :email AND type != :guest")->params(array(':email' => $this->email, ':guest' => 'guest'))->one();
}

if ($user) {

+ 1
- 1
domain/User/UserProducer/UserProducerRepository.php Datei anzeigen

@@ -17,7 +17,7 @@ class UserProducerRepository extends AbstractRepository
public function getDefaultOptionsSearch(): array
{
return [
self::WITH => ['producer'],
self::WITH => [],
self::JOIN_WITH => [],
self::ORDER_BY => '',
self::ATTRIBUTE_ID_PRODUCER => 'user_producer.id_producer'

Laden…
Abbrechen
Speichern