Track last engagement only once per minute

[MAILPOET-3762]
This commit is contained in:
Rostislav Wolny
2021-08-31 13:05:06 +02:00
committed by Veljko V
parent 9c3fc95a6d
commit b215ab13c8
2 changed files with 26 additions and 0 deletions

View File

@@ -312,6 +312,10 @@ class SubscribersRepository extends Repository {
if ($userAgent instanceof UserAgentEntity && $userAgent->getUserAgentType() === UserAgentEntity::USER_AGENT_TYPE_MACHINE) {
return;
}
// Do not update engagement if was recently updated to avoid unnecessary updates in DB
if ($subscriberEntity->getLastEngagementAt() && $subscriberEntity->getLastEngagementAt() > Carbon::now()->subMinute()) {
return;
}
// Update last engagement for human (and also unknown) user agent
$subscriberEntity->setLastEngagementAt(Carbon::now());
$this->flush();