Skip to content

Commit

Permalink
[EPC-9597] Update crontab schedule and use constants for DB table alias
Browse files Browse the repository at this point in the history
  • Loading branch information
Can Demiralp committed Feb 14, 2025
1 parent 90938fe commit e8d5fd1
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
2 changes: 2 additions & 0 deletions Api/Data/NotificationInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ interface NotificationInterface
/**
* Constants for keys of data array. Identical to the name of the getter in snake case.
*/
const TABLE_NAME = 'adyen_notification';
const TABLE_NAME_ALIAS = 'notification';
const ENTITY_ID = 'entity_id';
const PSPREFRENCE = 'pspreference';
const ORIGINAL_REFERENCE = 'original_reference';
Expand Down
2 changes: 1 addition & 1 deletion Model/Config/Backend/ProcessedWebhookRemoval.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function afterSave(): ProcessedWebhookRemoval
if ($this->isValueChanged() && $this->getValue() === '1') {
$numberOfDays = $this->getFieldsetDataValue('processed_webhook_removal_time');
$message = __(
'You enabled the automatic removal of Adyen's processed webhooks. Processed webhooks older than %1 days will be removed.',
'You enabled the automatic removal of Adyen\'s processed webhooks. Processed webhooks older than %1 days will be removed.',
$numberOfDays
);

Expand Down
14 changes: 11 additions & 3 deletions Model/ResourceModel/Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Adyen\Payment\Model\ResourceModel;

use Adyen\Payment\Api\Data\NotificationInterface;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;

Expand Down Expand Up @@ -70,9 +71,16 @@ public function deleteByIds(array $entityIds): void

$connection = $this->getConnection();
$select = $connection->select()
->from(['notification' => $tableName])
->where('notification.entity_id IN (?)', $entityIds);
->from([NotificationInterface::TABLE_NAME_ALIAS => $tableName])
->where(
sprintf(
"%s.%s IN (?)",
NotificationInterface::TABLE_NAME_ALIAS,
NotificationInterface::ENTITY_ID
),
$entityIds
);

$connection->query($select->deleteFromSelect('notification'));
$connection->query($select->deleteFromSelect(NotificationInterface::TABLE_NAME_ALIAS));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function testAfterSave()
// Set old value as `0` to mimic the disabled feature
$this->configMock->method('getValue')->willReturn('0');
$expectedMessage =
'You enabled processed webhook removal cronjob. Processed webhooks older than 45 days will be removed.';
'You enabled the automatic removal of Adyen\'s processed webhooks. Processed webhooks older than 45 days will be removed.';

$this->messageManagerMock->expects($this->once())
->method('addWarningMessage')
Expand Down
2 changes: 1 addition & 1 deletion etc/crontab.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<schedule>0 0 * * *</schedule>
</job>
<job name="adyen_payment_remove_processed_webhooks" instance="Adyen\Payment\Cron\RemoveProcessedWebhooks" method="execute">
<schedule>0 0 * * *</schedule>
<schedule>*/5 0 * * *</schedule>
</job>
</group>
</config>

0 comments on commit e8d5fd1

Please sign in to comment.