Files
piratepoet/lib/Models/StatisticsOpens.php
Rodrigo Primo 8b7815caf8 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]
2021-08-25 17:01:33 +02:00

28 lines
774 B
PHP

<?php
namespace MailPoet\Models;
/**
* @property int $newsletterId
* @property int $subscriberId
* @property int $queueId
*/
class StatisticsOpens extends Model {
public static $_table = MP_STATISTICS_OPENS_TABLE; // phpcs:ignore PSR2.Classes.PropertyDeclaration
public static function getOrCreate($subscriberId, $newsletterId, $queueId) {
$statistics = self::where('subscriber_id', $subscriberId)
->where('newsletter_id', $newsletterId)
->where('queue_id', $queueId)
->findOne();
if (!$statistics) {
$statistics = self::create();
$statistics->subscriberId = $subscriberId;
$statistics->newsletterId = $newsletterId;
$statistics->queueId = $queueId;
$statistics->save();
}
return $statistics;
}
}