| Total Complexity | 5 |
| Total Lines | 53 |
| Duplicated Lines | 0 % |
| Coverage | 52.94% |
| Changes | 1 | ||
| Bugs | 1 | Features | 1 |
| 1 | <?php |
||
| 12 | trait RecordsTrait |
||
| 13 | { |
||
| 14 | protected static $sentDateField = 'date_sent'; |
||
| 15 | |||
| 16 | protected $daysToKeepData = 500; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @return \Nip\Database\Result |
||
| 20 | */ |
||
| 21 | 1 | public function reduceOldEmailsData() |
|
| 22 | { |
||
| 23 | /** @var Update $query */ |
||
| 24 | 1 | $query = $this->newUpdateQuery(); |
|
|
|
|||
| 25 | 1 | $query->where( |
|
| 26 | 1 | '`' . $this::getSentDateField() . '` <= DATE_SUB(CURRENT_DATE(), INTERVAL ' . $this->daysToKeepData . ' DAY)' |
|
| 27 | ); |
||
| 28 | 1 | $query->data([ |
|
| 29 | 1 | 'vars' => '', |
|
| 30 | 'body' => '', |
||
| 31 | 'compiled_subject' => '', |
||
| 32 | 'compiled_body' => '', |
||
| 33 | ]); |
||
| 34 | |||
| 35 | 1 | return $query->execute(); |
|
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * @return string |
||
| 40 | */ |
||
| 41 | 2 | public static function getSentDateField(): string |
|
| 42 | { |
||
| 43 | 2 | return self::$sentDateField; |
|
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * @param string $sentDateField |
||
| 48 | */ |
||
| 49 | public static function setSentDateField(string $sentDateField) |
||
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * @return float[]|int[] |
||
| 56 | */ |
||
| 57 | public static function reduceEmailsByType(): array |
||
| 65 | } |
||
| 66 | } |
||
| 67 |