Skip to content
Extraits de code Groupes Projets
Valider 1b37b759 rédigé par mattab's avatar mattab
Parcourir les fichiers

Minor

parent a1c6c2e5
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -164,6 +164,7 @@ class Loader
protected function computeNewArchive($enforceProcessCoreMetricsOnly)
{
$isArchiveDay = $this->params->isDayArchive();
$archiveWriter = new ArchiveWriter($this->params->getSite()->getId(), $this->params->getSegment(), $this->params->getPeriod(), $this->params->getRequestedPlugin(), $this->isArchiveTemporary());
$archiveWriter->initNewArchive();
......@@ -191,8 +192,8 @@ class Loader
$archiveProcessor = $this->makeArchiveProcessor($archiveWriter);
$isVisitsToday = $this->getNumberOfVisits() > 0;
if ($isVisitsToday
$wereThereVisits = $this->getNumberOfVisits() > 0;
if ($wereThereVisits
&& !$enforceProcessCoreMetricsOnly
) {
$pluginsArchiver = new PluginsArchiver($archiveProcessor);
......@@ -201,7 +202,7 @@ class Loader
$archiveWriter->finalizeArchive();
if ($isVisitsToday && !$isArchiveDay) {
if ($wereThereVisits && !$isArchiveDay) {
ArchiveSelector::purgeOutdatedArchives($this->params->getPeriod()->getDateStart());
}
......
......@@ -42,11 +42,14 @@ class Test_Piwik_Fixture_TwoSitesEcommerceOrderWithItems extends Test_Piwik_Base
private function trackVisits()
{
$dateTime = $this->dateTime;
$idSite = $this->idSite;
$idSite2 = $this->idSite2;
$this->trackVisitsSite1();
$this->trackVisitsSite2();
}
private function trackVisitsSite1()
{
$t = self::getTracker($this->idSite, $this->dateTime, $defaultInit = true);
$t = self::getTracker($idSite, $dateTime, $defaultInit = true);
// VISIT NO 1
$t->setUrl('http://example.org/index.htm');
$category = 'Electronics & Cameras';
......@@ -63,16 +66,16 @@ class Test_Piwik_Fixture_TwoSitesEcommerceOrderWithItems extends Test_Piwik_Base
self::assertEquals(array('VisitorType', 'NewLoggedOut'), $t->getCustomVariable(5, 'visit'));
self::checkResponse($t->doTrackPageView('incredible title!'));
$t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.1)->getDatetime());
$t->setForceVisitDateTime(Date::factory($this->dateTime)->addHour(0.1)->getDatetime());
$t->setEcommerceView($sku = 'SKU VERY nice indeed', $name = 'PRODUCT name', $category, $price = 666);
self::checkResponse($t->doTrackPageView('Another Product page'));
// Note: here testing to pass a timestamp to the tracking API rather than the datetime string
$t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.2)->getTimestampUTC());
$t->setForceVisitDateTime(Date::factory($this->dateTime)->addHour(0.2)->getTimestampUTC());
$t->setEcommerceView($sku = 'SKU VERY nice indeed', $name = 'PRODUCT name', '');
self::checkResponse($t->doTrackPageView('Another Product page with no category'));
$t->setForceVisitDateTime(Date::factory($dateTime)->addHour(0.2)->getDatetime());
$t->setForceVisitDateTime(Date::factory($this->dateTime)->addHour(0.2)->getDatetime());
$t->setEcommerceView($sku = 'SKU VERY nice indeed', $name = 'PRODUCT name', $categories = array('Multiple Category 1', '', 0, 'Multiple Category 2', 'Electronics & Cameras', 'Multiple Category 4', 'Multiple Category 5', 'SHOULD NOT BE REPORTEDSSSSSSSSSSSSSSssssssssssssssssssssssssssstttttttttttttttttttttttuuuu!'));
self::checkResponse($t->doTrackPageView('Another Product page with multiple categories'));
......@@ -82,22 +85,22 @@ class Test_Piwik_Fixture_TwoSitesEcommerceOrderWithItems extends Test_Piwik_Base
$t->setDebugStringAppend("&_idvc=2");
// VIEW category page
$t->setForceVisitDateTime(Date::factory($dateTime)->addHour(1.6)->getDatetime());
$t->setForceVisitDateTime(Date::factory($this->dateTime)->addHour(1.6)->getDatetime());
$t->setEcommerceView('', '', $category);
self::checkResponse($t->doTrackPageView('Looking at ' . $category . ' page with a page level custom variable'));
// VIEW category page again
$t->setForceVisitDateTime(Date::factory($dateTime)->addHour(1.7)->getDatetime());
$t->setForceVisitDateTime(Date::factory($this->dateTime)->addHour(1.7)->getDatetime());
$t->setEcommerceView('', '', $category);
self::checkResponse($t->doTrackPageView('Looking at ' . $category . ' page again'));
// VIEW product page
$t->setForceVisitDateTime(Date::factory($dateTime)->addHour(1.8)->getDatetime());
$t->setForceVisitDateTime(Date::factory($this->dateTime)->addHour(1.8)->getDatetime());
$t->setEcommerceView($sku = 'SKU VERY nice indeed', $name = 'PRODUCT name', $category = 'Electronics & Cameras', $price = 666);
self::checkResponse($t->doTrackPageView('Looking at product page'));
// ADD TO CART
$t->setForceVisitDateTime(Date::factory($dateTime)->addHour(1.9)->getDatetime());
$t->setForceVisitDateTime(Date::factory($this->dateTime)->addHour(1.9)->getDatetime());
$t->setCustomVariable(3, 'VisitorName', 'Great name!', 'visit');
$t->addEcommerceItem($sku = 'SKU VERY nice indeed', $name = 'PRODUCT name', $category = 'Electronics & Cameras', $price = 500, $quantity = 1);
$t->addEcommerceItem($sku = 'SKU VERY nice indeed', $name = 'PRODUCT name', $category = 'Electronics & Cameras', $price = 500, $quantity = 2);
......@@ -105,13 +108,13 @@ class Test_Piwik_Fixture_TwoSitesEcommerceOrderWithItems extends Test_Piwik_Base
self::checkResponse($t->doTrackEcommerceCartUpdate($grandTotal = 1000));
// ORDER NO 1
$t->setForceVisitDateTime(Date::factory($dateTime)->addHour(2)->getDatetime());
$t->setForceVisitDateTime(Date::factory($this->dateTime)->addHour(2)->getDatetime());
$t->addEcommerceItem($sku = 'SKU VERY nice indeed', $name = 'PRODUCT name', $categories, $price = 500, $quantity = 2);
$t->addEcommerceItem($sku = 'ANOTHER SKU HERE', $name = 'PRODUCT name BIS', $category = '', $price = 100, $quantity = 6);
self::checkResponse($t->doTrackEcommerceOrder($orderId = '937nsjusu 3894', $grandTotal = 1111.11, $subTotal = 1000, $tax = 111, $shipping = 0.11, $discount = 666));
// ORDER NO 2
$t->setForceVisitDateTime(Date::factory($dateTime)->addHour(2.1)->getDatetime());
$t->setForceVisitDateTime(Date::factory($this->dateTime)->addHour(2.1)->getDatetime());
$t->addEcommerceItem($sku = 'SKU2', $name = 'Canon SLR', $category = 'Electronics & Cameras', $price = 1500, $quantity = 1);
// Product bought with empty category
$t->addEcommerceItem($sku = 'SKU VERY nice indeed', $name = 'PRODUCT name', '', $price = 11.22, $quantity = 1);
......@@ -127,19 +130,19 @@ class Test_Piwik_Fixture_TwoSitesEcommerceOrderWithItems extends Test_Piwik_Base
// ORDER SHOULD DEDUPE
// Refresh the page with the receipt for the second order, should be ignored
// we test that both the order, and the products, are not updated on subsequent "Receipt" views
$t->setForceVisitDateTime(Date::factory($dateTime)->addHour(2.2)->getDatetime());
$t->setForceVisitDateTime(Date::factory($this->dateTime)->addHour(2.2)->getDatetime());
$t->addEcommerceItem($sku = 'SKU2', $name = 'Canon SLR NOT!', $category = 'Electronics & Cameras NOT!', $price = 15000000000, $quantity = 10000);
self::checkResponse($t->doTrackEcommerceOrder($orderId = '1037nsjusu4s3894', $grandTotal = 20000000, $subTotal = 1500, $tax = 400, $shipping = 100, $discount = 0));
// Leave with an opened cart
// No category
$t->setForceVisitDateTime(Date::factory($dateTime)->addHour(2.3)->getDatetime());
$t->setForceVisitDateTime(Date::factory($this->dateTime)->addHour(2.3)->getDatetime());
$t->addEcommerceItem($sku = 'SKU IN ABANDONED CART ONE', $name = 'PRODUCT ONE LEFT in cart', $category = '', $price = 500.11111112, $quantity = 2);
self::checkResponse($t->doTrackEcommerceCartUpdate($grandTotal = 1000));
// Record the same visit leaving twice an abandoned cart
foreach (array(0, 5, 24) as $offsetHour) {
$t->setForceVisitDateTime(Date::factory($dateTime)->addHour($offsetHour + 2.4)->getDatetime());
$t->setForceVisitDateTime(Date::factory($this->dateTime)->addHour($offsetHour + 2.4)->getDatetime());
// Also recording an order the day after
if ($offsetHour >= 24) {
$t->setDebugStringAppend("&_idvc=1");
......@@ -148,20 +151,20 @@ class Test_Piwik_Fixture_TwoSitesEcommerceOrderWithItems extends Test_Piwik_Base
}
// VIEW PRODUCT PAGES
$t->setForceVisitDateTime(Date::factory($dateTime)->addHour($offsetHour + 2.5)->getDatetime());
$t->setForceVisitDateTime(Date::factory($this->dateTime)->addHour($offsetHour + 2.5)->getDatetime());
$t->setEcommerceView($sku = 'SKU VERY nice indeed', $name = 'PRODUCT THREE LEFT in cart', $category = '', $price = 999);
self::checkResponse($t->doTrackPageView("View product left in cart"));
$t->setForceVisitDateTime(Date::factory($dateTime)->addHour($offsetHour + 2.55)->getDatetime());
$t->setForceVisitDateTime(Date::factory($this->dateTime)->addHour($offsetHour + 2.55)->getDatetime());
$t->setEcommerceView($sku = 'SKU VERY nice indeed', $name = 'PRODUCT THREE LEFT in cart', $category = '', $price = 333);
self::checkResponse($t->doTrackPageView("View product left in cart"));
$t->setForceVisitDateTime(Date::factory($dateTime)->addHour($offsetHour + 2.6)->getDatetime());
$t->setForceVisitDateTime(Date::factory($this->dateTime)->addHour($offsetHour + 2.6)->getDatetime());
$t->setEcommerceView($sku = 'SKU IN ABANDONED CART TWO', $name = 'PRODUCT TWO LEFT in cart', $category = 'Category TWO LEFT in cart');
self::checkResponse($t->doTrackPageView("View product left in cart"));
// ABANDONED CART
$t->setForceVisitDateTime(Date::factory($dateTime)->addHour($offsetHour + 2.7)->getDatetime());
$t->setForceVisitDateTime(Date::factory($this->dateTime)->addHour($offsetHour + 2.7)->getDatetime());
$t->addEcommerceItem($sku = 'SKU IN ABANDONED CART ONE', $name = 'PRODUCT ONE LEFT in cart', $category = '', $price = 500.11111112, $quantity = 1);
$t->addEcommerceItem($sku = 'SKU IN ABANDONED CART TWO', $name = 'PRODUCT TWO LEFT in cart', $category = 'Category TWO LEFT in cart', $price = 1000, $quantity = 2);
$t->addEcommerceItem($sku = 'SKU VERY nice indeed', $name = 'PRODUCT THREE LEFT in cart', $category = 'Electronics & Cameras', $price = 10, $quantity = 1);
......@@ -169,17 +172,24 @@ class Test_Piwik_Fixture_TwoSitesEcommerceOrderWithItems extends Test_Piwik_Base
}
// One more Ecommerce order to check weekly archiving works fine on orders
$t->setForceVisitDateTime(Date::factory($dateTime)->addHour(30.7)->getDatetime());
$t->setForceVisitDateTime(Date::factory($this->dateTime)->addHour(30.7)->getDatetime());
$t->addEcommerceItem($sku = 'TRIPOD SKU', $name = 'TRIPOD - bought day after', $category = 'Tools', $price = 100, $quantity = 2);
self::checkResponse($t->doTrackEcommerceOrder($orderId = '666', $grandTotal = 240, $subTotal = 200, $tax = 20, $shipping = 20, $discount = 20));
// One more Ecommerce order, without any product in it, because we still track orders without products
$t->setForceVisitDateTime(Date::factory($dateTime)->addHour(30.8)->getDatetime());
$t->setForceVisitDateTime(Date::factory($this->dateTime)->addHour(30.8)->getDatetime());
self::checkResponse($t->doTrackEcommerceOrder($orderId = '777', $grandTotal = 10000));
return array($defaultInit, $t, $category, $price, $sku, $name, $quantity, $grandTotal, $orderId);
}
/**
* @param $this->dateTime
*/
private function trackVisitsSite2()
{
// testing the same order in a different website should record
$t = self::getTracker($idSite2, $dateTime, $defaultInit = true);
$t->setForceVisitDateTime(Date::factory($dateTime)->addHour(30.9)->getDatetime());
$t = self::getTracker($this->idSite2, $this->dateTime, $defaultInit = true);
$t->setForceVisitDateTime(Date::factory($this->dateTime)->addHour(30.9)->getDatetime());
$t->addEcommerceItem($sku = 'TRIPOD SKU', $name = 'TRIPOD - bought day after', $category = 'Tools', $price = 100, $quantity = 2);
self::checkResponse($t->doTrackEcommerceOrder($orderId = '777', $grandTotal = 250));
//------------------------------------- End tracking
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter