diff --git a/src/Entity/PushNotificationHistory/PushNotificationHistoryInterface.php b/src/Entity/PushNotificationHistory/PushNotificationHistoryInterface.php index f9f0d9d..7385908 100644 --- a/src/Entity/PushNotificationHistory/PushNotificationHistoryInterface.php +++ b/src/Entity/PushNotificationHistory/PushNotificationHistoryInterface.php @@ -14,6 +14,8 @@ interface PushNotificationHistoryInterface extends ResourceInterface public const STATE_RECEIVED = 'received'; + public const RESPONSE_CREATED_CODE = 201; + public function getTitle(): string; public function setTitle(string $title): void; diff --git a/src/Repository/PushNotificationHistory/PushNotificationHistoryRepository.php b/src/Repository/PushNotificationHistory/PushNotificationHistoryRepository.php index ea47a3f..8775563 100644 --- a/src/Repository/PushNotificationHistory/PushNotificationHistoryRepository.php +++ b/src/Repository/PushNotificationHistory/PushNotificationHistoryRepository.php @@ -18,11 +18,13 @@ public function createOwnedByUserQueryBuilder(ShopUserInterface $user, ChannelIn ->innerJoin('pushNotificationHistory.user', 'user') ->where('user = :user') ->andWhere('pushNotificationHistory.channel = :channel') + ->andWhere('pushNotificationHistory.responseStatusCode = :code') ->setParameter('user', $user) - ->setParameter('channel', $channel); + ->setParameter('channel', $channel) + ->setParameter('code', PushNotificationHistoryInterface::RESPONSE_CREATED_CODE); } - public function getCountOfNotReceivedPushNotifications(ShopUserInterface $user, ChannelInterface $channel): int + public function getCountOfNotReceivedCustomerPushNotifications(ShopUserInterface $user, ChannelInterface $channel): int { return $this->createQueryBuilder('pushNotificationHistory') ->select('COUNT(pushNotificationHistory)') @@ -30,9 +32,11 @@ public function getCountOfNotReceivedPushNotifications(ShopUserInterface $user, ->where('user = :user') ->andWhere('pushNotificationHistory.state = :state') ->andWhere('pushNotificationHistory.channel = :channel') + ->andWhere('pushNotificationHistory.responseStatusCode = :code') ->setParameter('user', $user) ->setParameter('state', PushNotificationHistoryInterface::STATE_NOT_RECEIVED) ->setParameter('channel', $channel) + ->setParameter('code', PushNotificationHistoryInterface::RESPONSE_CREATED_CODE) ->getQuery() ->getSingleScalarResult(); } diff --git a/src/Repository/PushNotificationHistory/PushNotificationHistoryRepositoryInterface.php b/src/Repository/PushNotificationHistory/PushNotificationHistoryRepositoryInterface.php index a41ebb7..b11bada 100644 --- a/src/Repository/PushNotificationHistory/PushNotificationHistoryRepositoryInterface.php +++ b/src/Repository/PushNotificationHistory/PushNotificationHistoryRepositoryInterface.php @@ -14,7 +14,7 @@ interface PushNotificationHistoryRepositoryInterface extends RepositoryInterface { public function createOwnedByUserQueryBuilder(ShopUserInterface $user, ChannelInterface $channel): QueryBuilder; - public function getCountOfNotReceivedPushNotifications(ShopUserInterface $user, ChannelInterface $channel): int; + public function getCountOfNotReceivedCustomerPushNotifications(ShopUserInterface $user, ChannelInterface $channel): int; public function save(PushNotificationHistoryInterface $pushNotificationHistory): void; } diff --git a/src/Twig/Extension/PushNotificationHistoryTwigExtension.php b/src/Twig/Extension/PushNotificationHistoryTwigExtension.php index 2279d72..a048acd 100644 --- a/src/Twig/Extension/PushNotificationHistoryTwigExtension.php +++ b/src/Twig/Extension/PushNotificationHistoryTwigExtension.php @@ -31,6 +31,6 @@ public function getCountOfNotReceivedPushNotifications(ShopUserInterface $user): $channel = $this->channelContext->getChannel(); /** @var ChannelInterface $channel */ - return $this->pushNotificationHistoryRepository->getCountOfNotReceivedPushNotifications($user, $channel); + return $this->pushNotificationHistoryRepository->getCountOfNotReceivedCustomerPushNotifications($user, $channel); } }