-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #916 from algolia/develop
Develop
- Loading branch information
Showing
16 changed files
with
269 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
app/code/community/Algolia/Algoliasearch/Block/Adminhtml/Notifications.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
class Algolia_Algoliasearch_Block_Adminhtml_Notifications extends Mage_Adminhtml_Block_Template | ||
{ | ||
public function getConfigurationUrl() | ||
{ | ||
return $this->getUrl('adminhtml/system_config/edit/section/algoliasearch'); | ||
} | ||
|
||
public function getQueueInfo() | ||
{ | ||
/** @var Algolia_Algoliasearch_Helper_Config $config */ | ||
$config = Mage::helper('algoliasearch/config'); | ||
|
||
/** @var Mage_Core_Model_Resource $resource */ | ||
$resource = Mage::getSingleton('core/resource'); | ||
$tableName = $resource->getTableName('algoliasearch/queue'); | ||
|
||
$readConnection = $resource->getConnection('core_read'); | ||
|
||
$size = (int)$readConnection->query('SELECT COUNT(*) as total_count FROM '.$tableName)->fetchColumn(0); | ||
$maxJobsPerSingleRun = $config->getNumberOfJobToRun(); | ||
|
||
$etaMinutes = ceil($size / $maxJobsPerSingleRun) * 5; // 5 - assuming the queue runner runs every 5 minutes | ||
|
||
$eta = $etaMinutes.' minutes'; | ||
if ($etaMinutes > 60) { | ||
$hours = floor($etaMinutes / 60); | ||
$restMinutes = $etaMinutes % 60; | ||
|
||
$eta = $hours.' hours '.$restMinutes.' minutes'; | ||
} | ||
|
||
$queueInfo = array( | ||
'isEnabled' => $config->isQueueActive(), | ||
'currentSize' => $size, | ||
'eta' => $eta, | ||
); | ||
|
||
return $queueInfo; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...e/community/Algolia/Algoliasearch/sql/algoliasearch_setup/mysql4-upgrade-1.7.1-1.11.1.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
/** @var Mage_Core_Model_Resource_Setup $installer */ | ||
$installer = $this; | ||
$installer->startSetup(); | ||
|
||
$tableName = $installer->getTable('algoliasearch/queue'); | ||
$installer->run("ALTER TABLE `{$tableName}` ADD `created` DATETIME AFTER `job_id`;"); | ||
|
||
$installer->run(" | ||
CREATE TABLE IF NOT EXISTS `{$tableName}_log` ( | ||
`id` INT(20) NOT NULL auto_increment, | ||
`started` DATETIME NOT NULL, | ||
`duration` INT(20) NOT NULL, | ||
`processed_jobs` INT NOT NULL, | ||
`with_empty_queue` INT(1) NOT NULL, | ||
PRIMARY KEY `id` (`id`) | ||
) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8 AUTO_INCREMENT=1; | ||
"); | ||
|
||
$installer->endSetup(); |
10 changes: 10 additions & 0 deletions
10
app/design/adminhtml/default/default/layout/algoliasearch.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
app/design/adminhtml/default/default/template/algoliasearch/notifications.phtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
/** @var Algolia_Algoliasearch_Block_Adminhtml_Notifications $this */ | ||
|
||
$queueInfo = $this->getQueueInfo(); | ||
|
||
?> | ||
|
||
<div class="notification-global algoliasearch-queue-notification"> <!-- TODO FIX the SKIN URL --> | ||
<strong>Algolia Search</strong> - | ||
<?php if($queueInfo['isEnabled'] === true):?> | ||
<strong> | ||
<a href="<?php echo $this->getConfigurationUrl(); ?>">Indexing queue</a> information: | ||
</strong> | ||
|
||
Number of queued jobs: <strong><?php echo $queueInfo['currentSize']; ?></strong>, | ||
|
||
<?php if ($queueInfo['currentSize'] > 0): ?> | ||
all queued jobs will be processed in appr. <strong><?php echo $queueInfo['eta']; ?></strong>, | ||
<?php endif; ?> | ||
|
||
more information about how the indexing queue works you can find in the documentation: <a href="https://community.algolia.com/magento/doc/m1/indexing/?utm_source=magento&utm_medium=extension&utm_campaign=magento_1&utm_term=shop-owner&utm_content=doc-link#general-information" target="_blank">Indexing queue</a> | ||
<?php else: ?> | ||
<strong> | ||
<a href="<?php echo $this->getConfigurationUrl(); ?>">Indexing queue</a> is not enabled. | ||
</strong> | ||
|
||
It's highly recommended to enable it, especially if you are on production environment. You can learn how to enable the index queue in the documentation: <a href="https://community.algolia.com/magento/doc/m1/indexing/?utm_source=magento&utm_medium=extension&utm_campaign=magento_1&utm_term=shop-owner&utm_content=doc-link#general-information" target="_blank">Indexing queue</a> | ||
<?php endif; ?> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.algoliasearch-queue-notification { | ||
background: #e9f3ff url(/skin/frontend/base/default/algoliasearch/algolia-admin-menu.svg) no-repeat 27px 5px; | ||
background-size: 16px 16px; | ||
border-color: #bee1ee; | ||
} |
Oops, something went wrong.