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:
@@ -3,9 +3,6 @@
|
||||
namespace MailPoet\Models;
|
||||
|
||||
use DateTimeInterface;
|
||||
use MailPoet\DI\ContainerWrapper;
|
||||
use MailPoet\Entities\UserAgentEntity;
|
||||
use MailPoetVendor\Doctrine\ORM\EntityManager;
|
||||
|
||||
/**
|
||||
* @property int $newsletterId
|
||||
@@ -17,35 +14,6 @@ use MailPoetVendor\Doctrine\ORM\EntityManager;
|
||||
class StatisticsClicks extends Model {
|
||||
public static $_table = MP_STATISTICS_CLICKS_TABLE; // phpcs:ignore PSR2.Classes.PropertyDeclaration
|
||||
|
||||
public static function getAllForSubscriber(Subscriber $subscriber) {
|
||||
$entityManager = ContainerWrapper::getInstance()->get(EntityManager::class);
|
||||
$userAgentsTable = $entityManager->getClassMetadata(UserAgentEntity::class)->getTableName();
|
||||
|
||||
return static::tableAlias('clicks')
|
||||
->select('clicks.id', 'id')
|
||||
->select('newsletter_rendered_subject')
|
||||
->select('clicks.created_at', 'created_at')
|
||||
->select('url')
|
||||
->select('user_agent.user_agent')
|
||||
->join(
|
||||
SendingQueue::$_table,
|
||||
['clicks.queue_id', '=', 'queue.id'],
|
||||
'queue'
|
||||
)
|
||||
->join(
|
||||
NewsletterLink::$_table,
|
||||
['clicks.link_id', '=', 'link.id'],
|
||||
'link'
|
||||
)
|
||||
->leftOuterJoin(
|
||||
$userAgentsTable,
|
||||
['clicks.user_agent_id', '=', 'user_agent.id'],
|
||||
'user_agent'
|
||||
)
|
||||
->where('clicks.subscriber_id', $subscriber->id())
|
||||
->orderByAsc('url');
|
||||
}
|
||||
|
||||
public static function findLatestPerNewsletterBySubscriber(Subscriber $subscriber, DateTimeInterface $from, DateTimeInterface $to) {
|
||||
// subquery to find latest click IDs for each newsletter
|
||||
$table = self::$_table;
|
||||
|
Reference in New Issue
Block a user