Update woo revenue stats to only look at past year

MAILPOET-5410
This commit is contained in:
John Oleksowicz
2023-07-21 16:39:40 -05:00
committed by Aschepikov
parent 62ac4d5e27
commit f0f24552f0

View File

@ -101,14 +101,18 @@ class SubscriberStatisticsRepository extends Repository {
return null;
}
$dateTime = (new Carbon())->subYear();
$currency = $this->wcHelper->getWoocommerceCurrency();
$purchases = $this->entityManager->createQueryBuilder()
->select('stats.orderPriceTotal')
->from(StatisticsWooCommercePurchaseEntity::class, 'stats')
->where('stats.subscriber = :subscriber')
->andWhere('stats.orderCurrency = :currency')
->andWhere('stats.createdAt > :dateTime')
->setParameter('subscriber', $subscriber)
->setParameter('currency', $currency)
->setParameter('dateTime', $dateTime)
->groupBy('stats.orderId, stats.orderPriceTotal')
->getQuery()
->getResult();