Skip to content

Commit

Permalink
Display push notification history only with response status code 201
Browse files Browse the repository at this point in the history
  • Loading branch information
TomaszLach2 committed Sep 8, 2023
1 parent 9d5882f commit 58aa21c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,25 @@ 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)')
->innerJoin('pushNotificationHistory.user', '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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 58aa21c

Please sign in to comment.