Skip to content

Commit

Permalink
version $VERSION
Browse files Browse the repository at this point in the history
  • Loading branch information
fryckbos committed Aug 1, 2016
1 parent c97bdb4 commit b028d2a
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/code/community/CoScale/Monitor/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function isEnabled()

foreach ($tables as $id => $data) {
$metricTable = $resource->getTableName($data['table']);
if (! $connection->isTableExists(Mage::getConfig()->getTablePrefix().$metricTable)) {
if (! $connection->isTableExists($metricTable)) {
$this->debugEndError('Module checking', new Exception('Table ' . $metricTable . ' not found!'));
return false;
}
Expand Down
1 change: 1 addition & 0 deletions app/code/community/CoScale/Monitor/Model/Cronjob.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ public function dailyCron()
// Customer metric data
Mage::getSingleton('coscale_monitor/metric_customer')->dailyCron();
Mage::getSingleton('coscale_monitor/metric_product')->dailyCron();
Mage::getSingleton('coscale_monitor/metric_order')->dailyCron();
}
}
33 changes: 26 additions & 7 deletions app/code/community/CoScale/Monitor/Model/Metric/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,16 +261,21 @@ public function initDefaultMetrics($storeId)
self::KEY_TIME_CURRENT_PICKPACK,
);

$amountUnit = Mage::getStoreConfig('currency/options/base', $storeId);

foreach ($initKeys as $key)
{
$metricData = $this->getMetric($key, $storeId);

// 'Amount' unit of a metric should always be replaced by the store currency
$unit = ($this->_metricData[$key]['unit'] == 'Amount' ? $amountUnit : $this->_metricData[$key]['unit']);
if (empty($metricData)) {
$this->setMetric(
self::ACTION_UPDATE,
$key,
$storeId,
0,
$this->_metricData[$key]['unit']
$unit
);
}
}
Expand Down Expand Up @@ -496,8 +501,7 @@ public function updateAvgOrderValues($storeId)
self::ACTION_UPDATE,
self::KEY_ORDER_SIZE_AVERAGE,
$storeId,
($orderItems/$orderTotal),
$amountUnit
($orderItems/$orderTotal)
);

$this->setMetric(
Expand All @@ -513,8 +517,7 @@ public function updateAvgOrderValues($storeId)
self::ACTION_UPDATE,
self::KEY_ORDER_SIZE_AVERAGE_NEW,
$storeId,
($newOrderItems / $newOrderTotal),
$amountUnit
($newOrderItems / $newOrderTotal)
);

$this->setMetric(
Expand Down Expand Up @@ -595,6 +598,8 @@ public function initOrderData()
}

foreach ($data as $storeId => $details) {
$amountUnit = Mage::getStoreConfig('currency/options/base', $storeId);

$this->setMetric(
self::ACTION_UPDATE,
self::KEY_ORDER_SIZE_TOTAL,
Expand All @@ -606,7 +611,8 @@ public function initOrderData()
self::ACTION_UPDATE,
self::KEY_ORDER_AMOUNT_TOTAL,
$storeId,
$details['amount']
$details['amount'],
$amountUnit
);

$this->setMetric(
Expand Down Expand Up @@ -663,6 +669,17 @@ public function initOrderData()
}
}

/**
* Cronjob to update the orders metrics
*/
public function dailyCron()
{
if (!$this->_helper->isEnabled()) {
return;
}
$this->initOrderData();
}

/**
* Generate output event
*
Expand Down Expand Up @@ -722,6 +739,8 @@ public function getAbandonnedCarts()
->group('main_table.store_id');
$output = array();
foreach ($collection as $order) {
$amountUnit = Mage::getStoreConfig('currency/options/base', (int)$order->getStoreId());

$output[] = array(
'name' => 'Abandonned carts',
'unit' => 'orders',
Expand All @@ -731,7 +750,7 @@ public function getAbandonnedCarts()
);
$output[] = array(
'name' => 'Total value of abandoned carts',
'unit' => 'Amount',
'unit' => $amountUnit,
'value' => (float)$order->getSubtotal(),
'store_id' => (int)$order->getStoreId(),
'type' => 'A'
Expand Down
2 changes: 1 addition & 1 deletion app/code/community/CoScale/Monitor/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<config>
<modules>
<CoScale_Monitor>
<version>0.13.0</version>
<version>0.15.0</version>
</CoScale_Monitor>
</modules>
<global>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
/**
* @package CoScale_Monitor
* @author Mihai Oprea <[email protected]>
* @created 2016-05-18
* @version 0.15.0
*/
$installer = $this;

$installer->startSetup();

$metric = $installer->getConnection();

/**
* Initialize order data for further delta processing
*/
Mage::getSingleton('coscale_monitor/metric_order')->initOrderData();
Mage::getSingleton('coscale_monitor/metric_customer')->updateTotalCount();
Mage::getSingleton('coscale_monitor/metric_product')->updateTotalCount();

$installer->endSetup();

0 comments on commit b028d2a

Please sign in to comment.