Use Doctrine for the opens and clicks exporters

This commit refactors the code that handles exporting e-mails opens and
clicks when generating the personal data file to use Doctrine instead of
Paris. I opted to do this in this task as opens and clicks code share
some functionality, and I didn't want to add more code that relies on
Paris, as we are eventually going to remove it.

[MAILPOET-3738]
This commit is contained in:
Rodrigo Primo
2021-08-19 16:54:06 -03:00
committed by Veljko V
parent 780ac5e53c
commit 8b7815caf8
11 changed files with 68 additions and 88 deletions

View File

@@ -2,10 +2,6 @@
namespace MailPoet\Models;
use MailPoet\DI\ContainerWrapper;
use MailPoet\Entities\UserAgentEntity;
use MailPoetVendor\Doctrine\ORM\EntityManager;
/**
* @property int $newsletterId
* @property int $subscriberId
@@ -28,27 +24,4 @@ class StatisticsOpens extends Model {
}
return $statistics;
}
public static function getAllForSubscriber(Subscriber $subscriber) {
$entityManager = ContainerWrapper::getInstance()->get(EntityManager::class);
$userAgentsTable = $entityManager->getClassMetadata(UserAgentEntity::class)->getTableName();
return static::tableAlias('opens')
->select('opens.id', 'id')
->select('newsletter_rendered_subject')
->select('opens.created_at', 'created_at')
->select('user_agent.user_agent')
->join(
SendingQueue::$_table,
['opens.queue_id', '=', 'queue.id'],
'queue'
)
->leftOuterJoin(
$userAgentsTable,
['opens.user_agent_id', '=', 'user_agent.id'],
'user_agent'
)
->where('opens.subscriber_id', $subscriber->id())
->orderByAsc('newsletter_rendered_subject');
}
}