Mark which fields support the "in the last" parameter for UI
[PREMIUM-253]
This commit is contained in:
@@ -32,6 +32,7 @@ class SubscriberAutomationFieldsFactory {
|
||||
'name' => $automation->getName() . " (#{$automation->getId()})",
|
||||
];
|
||||
}, $automations),
|
||||
'params' => ['in_the_last'],
|
||||
];
|
||||
|
||||
return [
|
||||
|
@@ -27,7 +27,10 @@ class SubscriberStatisticFieldsFactory {
|
||||
function (SubscriberPayload $payload, array $params = []) {
|
||||
$startTime = $this->getStartTime($params);
|
||||
return $this->subscriberStatisticsRepository->getTotalSentCount($payload->getSubscriber(), $startTime);
|
||||
}
|
||||
},
|
||||
[
|
||||
'params' => ['in_the_last'],
|
||||
]
|
||||
),
|
||||
new Field(
|
||||
'mailpoet:subscriber:email-opened-count',
|
||||
@@ -36,7 +39,10 @@ class SubscriberStatisticFieldsFactory {
|
||||
function (SubscriberPayload $payload, array $params = []) {
|
||||
$startTime = $this->getStartTime($params);
|
||||
return $this->subscriberStatisticsRepository->getStatisticsOpenCount($payload->getSubscriber(), $startTime);
|
||||
}
|
||||
},
|
||||
[
|
||||
'params' => ['in_the_last'],
|
||||
]
|
||||
),
|
||||
new Field(
|
||||
'mailpoet:subscriber:email-machine-opened-count',
|
||||
@@ -45,7 +51,10 @@ class SubscriberStatisticFieldsFactory {
|
||||
function (SubscriberPayload $payload, array $params = []) {
|
||||
$startTime = $this->getStartTime($params);
|
||||
return $this->subscriberStatisticsRepository->getStatisticsMachineOpenCount($payload->getSubscriber(), $startTime);
|
||||
}
|
||||
},
|
||||
[
|
||||
'params' => ['in_the_last'],
|
||||
]
|
||||
),
|
||||
new Field(
|
||||
'mailpoet:subscriber:email-clicked-count',
|
||||
@@ -54,7 +63,10 @@ class SubscriberStatisticFieldsFactory {
|
||||
function (SubscriberPayload $payload, array $params = []) {
|
||||
$startTime = $this->getStartTime($params);
|
||||
return $this->subscriberStatisticsRepository->getStatisticsClickCount($payload->getSubscriber(), $startTime);
|
||||
}
|
||||
},
|
||||
[
|
||||
'params' => ['in_the_last'],
|
||||
]
|
||||
),
|
||||
];
|
||||
}
|
||||
|
@@ -52,7 +52,10 @@ class CustomerOrderFieldsFactory {
|
||||
return $inTheLastSeconds === null
|
||||
? (float)$customer->get_total_spent()
|
||||
: $this->getRecentSpentTotal($customer, $inTheLastSeconds);
|
||||
}
|
||||
},
|
||||
[
|
||||
'params' => ['in_the_last'],
|
||||
]
|
||||
),
|
||||
new Field(
|
||||
'woocommerce:customer:spent-average',
|
||||
@@ -73,7 +76,10 @@ class CustomerOrderFieldsFactory {
|
||||
$orderCount = $this->getRecentOrderCount($customer, $inTheLastSeconds);
|
||||
}
|
||||
return $orderCount > 0 ? ($totalSpent / $orderCount) : 0.0;
|
||||
}
|
||||
},
|
||||
[
|
||||
'params' => ['in_the_last'],
|
||||
]
|
||||
),
|
||||
new Field(
|
||||
'woocommerce:customer:order-count',
|
||||
@@ -89,7 +95,10 @@ class CustomerOrderFieldsFactory {
|
||||
return $inTheLastSeconds === null
|
||||
? $customer->get_order_count()
|
||||
: $this->getRecentOrderCount($customer, $inTheLastSeconds);
|
||||
}
|
||||
},
|
||||
[
|
||||
'params' => ['in_the_last'],
|
||||
]
|
||||
),
|
||||
new Field(
|
||||
'woocommerce:customer:first-paid-order-date',
|
||||
@@ -132,6 +141,7 @@ class CustomerOrderFieldsFactory {
|
||||
},
|
||||
[
|
||||
'options' => $this->termOptionsBuilder->getTermOptions('product_cat'),
|
||||
'params' => ['in_the_last'],
|
||||
]
|
||||
),
|
||||
new Field(
|
||||
@@ -150,6 +160,7 @@ class CustomerOrderFieldsFactory {
|
||||
},
|
||||
[
|
||||
'options' => $this->termOptionsBuilder->getTermOptions('product_tag'),
|
||||
'params' => ['in_the_last'],
|
||||
]
|
||||
),
|
||||
];
|
||||
|
@@ -32,7 +32,10 @@ class CustomerReviewFieldsFactory {
|
||||
}
|
||||
$inTheLastSeconds = isset($params['in_the_last_seconds']) ? (int)$params['in_the_last_seconds'] : null;
|
||||
return $this->getUniqueProductReviewCount($customer, $inTheLastSeconds);
|
||||
}
|
||||
},
|
||||
[
|
||||
'params' => ['in_the_last'],
|
||||
]
|
||||
),
|
||||
new Field(
|
||||
'woocommerce:customer:last-review-date',
|
||||
|
@@ -36,11 +36,14 @@ class SubscriberAutomationFieldsFactoryTest extends MailPoetTest {
|
||||
$field = $fields[$key];
|
||||
$this->assertSame($name, $field->getName());
|
||||
$this->assertSame('enum_array', $field->getType());
|
||||
$this->assertSame(['options' => [
|
||||
['id' => $deactivating->getId(), 'name' => "Deactivating (#{$deactivating->getId()})"],
|
||||
['id' => $active->getId(), 'name' => "Active (#{$active->getId()})"],
|
||||
['id' => $draft->getId(), 'name' => "Draft (#{$draft->getId()})"],
|
||||
]], $field->getArgs());
|
||||
$this->assertSame([
|
||||
'options' => [
|
||||
['id' => $deactivating->getId(), 'name' => "Deactivating (#{$deactivating->getId()})"],
|
||||
['id' => $active->getId(), 'name' => "Active (#{$active->getId()})"],
|
||||
['id' => $draft->getId(), 'name' => "Draft (#{$draft->getId()})"],
|
||||
],
|
||||
'params' => ['in_the_last'],
|
||||
], $field->getArgs());
|
||||
}
|
||||
|
||||
// check values
|
||||
|
@@ -30,7 +30,9 @@ class SubscriberStatisticsFieldsFactoryTest extends MailPoetTest {
|
||||
$field = $fields['mailpoet:subscriber:email-sent-count'];
|
||||
$this->assertSame('Email — sent count', $field->getName());
|
||||
$this->assertSame('integer', $field->getType());
|
||||
$this->assertSame([], $field->getArgs());
|
||||
$this->assertSame([
|
||||
'params' => ['in_the_last'],
|
||||
], $field->getArgs());
|
||||
|
||||
// check values
|
||||
$payload = new SubscriberPayload($subscriber);
|
||||
@@ -60,7 +62,9 @@ class SubscriberStatisticsFieldsFactoryTest extends MailPoetTest {
|
||||
$field = $fields['mailpoet:subscriber:email-opened-count'];
|
||||
$this->assertSame('Email — opened count', $field->getName());
|
||||
$this->assertSame('integer', $field->getType());
|
||||
$this->assertSame([], $field->getArgs());
|
||||
$this->assertSame([
|
||||
'params' => ['in_the_last'],
|
||||
], $field->getArgs());
|
||||
|
||||
// check values
|
||||
$payload = new SubscriberPayload($subscriber);
|
||||
@@ -90,7 +94,9 @@ class SubscriberStatisticsFieldsFactoryTest extends MailPoetTest {
|
||||
$field = $fields['mailpoet:subscriber:email-machine-opened-count'];
|
||||
$this->assertSame('Email — machine opened count', $field->getName());
|
||||
$this->assertSame('integer', $field->getType());
|
||||
$this->assertSame([], $field->getArgs());
|
||||
$this->assertSame([
|
||||
'params' => ['in_the_last'],
|
||||
], $field->getArgs());
|
||||
|
||||
// check values
|
||||
$payload = new SubscriberPayload($subscriber);
|
||||
@@ -121,7 +127,9 @@ class SubscriberStatisticsFieldsFactoryTest extends MailPoetTest {
|
||||
$field = $fields['mailpoet:subscriber:email-clicked-count'];
|
||||
$this->assertSame('Email — clicked count', $field->getName());
|
||||
$this->assertSame('integer', $field->getType());
|
||||
$this->assertSame([], $field->getArgs());
|
||||
$this->assertSame([
|
||||
'params' => ['in_the_last'],
|
||||
], $field->getArgs());
|
||||
|
||||
// check values
|
||||
$payload = new SubscriberPayload($subscriber);
|
||||
|
@@ -22,17 +22,23 @@ class CustomerOrderFieldsFactoryTest extends \MailPoetTest {
|
||||
$spentTotalField = $fields['woocommerce:customer:spent-total'];
|
||||
$this->assertSame('Total spent', $spentTotalField->getName());
|
||||
$this->assertSame('number', $spentTotalField->getType());
|
||||
$this->assertSame([], $spentTotalField->getArgs());
|
||||
$this->assertSame([
|
||||
'params' => ['in_the_last'],
|
||||
], $spentTotalField->getArgs());
|
||||
|
||||
$spentAverageField = $fields['woocommerce:customer:spent-average'];
|
||||
$this->assertSame('Average spent', $spentAverageField->getName());
|
||||
$this->assertSame('number', $spentAverageField->getType());
|
||||
$this->assertSame([], $spentAverageField->getArgs());
|
||||
$this->assertSame([
|
||||
'params' => ['in_the_last'],
|
||||
], $spentAverageField->getArgs());
|
||||
|
||||
$orderCountField = $fields['woocommerce:customer:order-count'];
|
||||
$this->assertSame('Order count', $orderCountField->getName());
|
||||
$this->assertSame('integer', $orderCountField->getType());
|
||||
$this->assertSame([], $orderCountField->getArgs());
|
||||
$this->assertSame([
|
||||
'params' => ['in_the_last'],
|
||||
], $orderCountField->getArgs());
|
||||
|
||||
// check values (guest)
|
||||
$this->createOrder(0, 12.3);
|
||||
@@ -150,6 +156,7 @@ class CustomerOrderFieldsFactoryTest extends \MailPoetTest {
|
||||
['id' => $cat3Id, 'name' => 'Cat 3'],
|
||||
['id' => $uncategorizedId, 'name' => 'Uncategorized'],
|
||||
],
|
||||
'params' => ['in_the_last'],
|
||||
], $purchasedCategories->getArgs());
|
||||
|
||||
// create products
|
||||
@@ -225,6 +232,7 @@ class CustomerOrderFieldsFactoryTest extends \MailPoetTest {
|
||||
['id' => $tag2Id, 'name' => 'Tag 2'],
|
||||
['id' => $tag3Id, 'name' => 'Tag 3'],
|
||||
],
|
||||
'params' => ['in_the_last'],
|
||||
], $purchasedTags->getArgs());
|
||||
|
||||
// create products
|
||||
|
@@ -19,7 +19,9 @@ class CustomerReviewFieldsFactoryTest extends \MailPoetTest {
|
||||
$reviewCountField = $fields['woocommerce:customer:review-count'];
|
||||
$this->assertSame('Review count', $reviewCountField->getName());
|
||||
$this->assertSame('integer', $reviewCountField->getType());
|
||||
$this->assertSame([], $reviewCountField->getArgs());
|
||||
$this->assertSame([
|
||||
'params' => ['in_the_last'],
|
||||
], $reviewCountField->getArgs());
|
||||
|
||||
// check values (guest)
|
||||
$this->createProductReview(0, '', 1);
|
||||
|
Reference in New Issue
Block a user