Model/ResourceModel/Importer.php
public function cleanup($tableName)
    {
        try {
            $interval = $this->dateIntervalFactory->create(['interval_spec' => 'P30D']);
            $date = $this->localeDate->date()->sub($interval)->format('Y-m-d H:i:s');
            $conn = $this->getConnection();
            $num = $conn->delete(
                $this->getTable($tableName),
                ['created_at < ?' => $date]
            );

            return $num;
        } catch (\Exception $e) {
            return $e->getMessage();
        }
    }
public function cleanup($tableName)
    {
        try {
            $interval = $this->dateIntervalFactory->create(['interval_spec' => 'P30D']);
            $date = $this->localeDate->date()->sub($interval)->format('Y-m-d H:i:s');
            $conn = $this->getConnection();
            $num = $conn->delete(
                $this->getTable($tableName),
                ['created_at < ?' => $date]
            );

            return $num;
        } catch (\Exception $e) {
            return $e->getMessage();
        }
    }
public function cleanup ( $ tableName ) { try { $ interval = $ this -> dateIntervalFactory -> create ( [ 'interval_spec' => 'P30D' ] ) ; $ date = $ this -> localeDate -> date ( ) -> sub ( $ interval ) -> format ( 'Y-m-d H:i:s' ) ; $ conn = $ this -> getConnection ( ) ; $ num = $ conn -> delete ( $ this -> getTable ( $ tableName ) , [ 'created_at < ?' => $ date ] ) ; return $ num ; } catch ( \ Exception $ e ) { return $ e -> getMessage ( ) ; } }
Delete completed records older then 30 days from provided table.

@param string $tableName

@return \Exception|int
Delete completed records older then 30 days from provided table .