Deletion of Delivery Servers Usage Logs and Campaigns Delivery Logs

The idea is to delete only logs that are few months older.
Actually, you know what, open /apps/console/commands/DailyCommand.php and look for:
PHP:
protected function deleteDeliveryServersUsageLogs()
{
    try {
        $connection = Yii::app()->getDb();
        $connection->createCommand('DELETE FROM `{{delivery_server_usage_log}}` WHERE date_added < DATE_SUB(NOW(), INTERVAL 1 YEAR)')->execute();   
    } catch (Exception $e) {
        Yii::log($e->getMessage(), CLogger::LEVEL_ERROR);
    }
    return $this;
}

and make it
PHP:
protected function deleteDeliveryServersUsageLogs()
{
    try {
        $connection = Yii::app()->getDb();
        $connection->createCommand('DELETE FROM `{{delivery_server_usage_log}}` WHERE date_added < DATE_SUB(NOW(), INTERVAL 3 MONTH)')->execute();   
    } catch (Exception $e) {
        Yii::log($e->getMessage(), CLogger::LEVEL_ERROR);
    }
    return $this;
}
That way you delete logs older than 3 months, automatically, each day. I also adjsuted the core app to do like so, so the change is safe for updates.


It's the cron jobs more than sure, see https://kb.mailwizz.com/articles/my-campaigns-dont-send-theyre-stuck-in-pending-sending-status/ and https://kb.mailwizz.com/articles/debug-send-campaigns-command/

Hi @twisted1919,
Could the interval be changed from 3 to 1 month in this string?
$connection->createCommand('DELETE FROM `{{delivery_server_usage_log}}` WHERE date_added < DATE_SUB(NOW(), INTERVAL 3 MONTH)')->execute();

thanks
 
@Marcello - the current signature is:
PHP:
/**
* @return $this
*/
protected function deleteDeliveryServersUsageLogs()
{
    try {
        $options      = Yii::app()->options;
        $daysRemoval  = (int)$options->get('system.cron.process_delivery_bounce.delivery_servers_usage_logs_removal_days', 90);
        
        $connection = Yii::app()->getDb();
        $connection->createCommand(sprintf('DELETE FROM `{{delivery_server_usage_log}}` WHERE date_added < DATE_SUB(NOW(), INTERVAL %d DAY)', $daysRemoval))->execute();    
    } catch (Exception $e) {

        $this->stdout(__LINE__ . ': ' . $e->getMessage());
        Yii::log($e->getMessage(), CLogger::LEVEL_ERROR);
    }
    return $this;
}

Which mean s you can set this from backend > cron area ;)
 
@Marcello - the current signature is:
PHP:
/**
* @return $this
*/
protected function deleteDeliveryServersUsageLogs()
{
    try {
        $options      = Yii::app()->options;
        $daysRemoval  = (int)$options->get('system.cron.process_delivery_bounce.delivery_servers_usage_logs_removal_days', 90);
       
        $connection = Yii::app()->getDb();
        $connection->createCommand(sprintf('DELETE FROM `{{delivery_server_usage_log}}` WHERE date_added < DATE_SUB(NOW(), INTERVAL %d DAY)', $daysRemoval))->execute();   
    } catch (Exception $e) {

        $this->stdout(__LINE__ . ': ' . $e->getMessage());
        Yii::log($e->getMessage(), CLogger::LEVEL_ERROR);
    }
    return $this;
}

Which mean s you can set this from backend > cron area ;)

Sorry @twisted1919 ,
I forget to specify the MW version.
whith the last MW version I can manage this from backend as you explained here.
But I have to change this on 1.3.7.2 version, so I ask you if it's the same set 3 or 1 month.

Thanks
 
Back
Top