Skip to content

Commit

Permalink
Merge pull request #192 from david-fuehr/master
Browse files Browse the repository at this point in the history
speed up api calls for transaction status messages
  • Loading branch information
hreinberger authored Jul 27, 2018
2 parents 14281a5 + b00cbb4 commit 5249872
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
39 changes: 36 additions & 3 deletions Setup/UpgradeSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@

namespace Payone\Core\Setup;

use Magento\Framework\DB\Ddl\Table;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\SchemaSetupInterface;
use Magento\Framework\Setup\UpgradeSchemaInterface;
use Magento\Framework\DB\Ddl\Table;
use Payone\Core\Setup\Tables\Api;
use Payone\Core\Setup\Tables\PaymentBan;
use Payone\Core\Setup\Tables\Transactionstatus;

/**
* Magento script for updating the database after the initial installation
Expand All @@ -40,7 +42,7 @@ class UpgradeSchema extends BaseSchema implements UpgradeSchemaInterface
/**
* Upgrade method
*
* @param SchemaSetupInterface $setup
* @param SchemaSetupInterface $setup
* @param ModuleContextInterface $context
* @return void
*/
Expand Down Expand Up @@ -75,7 +77,7 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con
if (!$setup->getConnection()->isTableExists($setup->getTable(PaymentBan::TABLE_PAYMENT_BAN))) {
$this->addTable($setup, PaymentBan::getData());
}
if (version_compare($context->getVersion(), '2.3.0', '<=')) {// pre update version is lower than 1.3.0
if (version_compare($context->getVersion(), '2.3.0', '<=')) {
$setup->getConnection()->modifyColumn(
$setup->getTable('payone_protocol_api'),
'mid', ['type' => Table::TYPE_INTEGER, 'default' => '0']
Expand All @@ -89,5 +91,36 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con
'portalid', ['type' => Table::TYPE_INTEGER, 'default' => '0']
);
}

/*
* add index to payone_protocol_api::txid to speed up transaction status calls
*/
if (version_compare($context->getVersion(), '2.3.1', '<=')) {

$connection = $setup->getConnection();
$protocolApiTable = $connection->getTableName(Api::TABLE_PROTOCOL_API);
$indexField = 'txid';

$connection->addIndex(
$protocolApiTable,
$connection->getIndexName($protocolApiTable, $indexField),
$indexField
);

$transactionStatusTable = $connection->getTableName(Transactionstatus::TABLE_PROTOCOL_TRANSACTIONSTATUS);
$indexFieldTxid = 'txid';
$indexFieldCustomerid = 'customerid';

$connection->addIndex(
$transactionStatusTable,
$connection->getIndexName($transactionStatusTable, $indexFieldTxid),
$indexFieldTxid
);
$connection->addIndex(
$transactionStatusTable,
$connection->getIndexName($transactionStatusTable, $indexFieldCustomerid),
$indexFieldCustomerid
);
}
}
}
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
<module name="Payone_Core" setup_version="2.3.1">
<module name="Payone_Core" setup_version="2.3.2">
<sequence>
<module name="Magento_Quote" />
<module name="Magento_Sales" />
Expand Down

0 comments on commit 5249872

Please sign in to comment.