code/model/KapostConversionHistory.php
protected function onAfterWrite() {
        parent::onAfterWrite();
        
        $records=KapostConversionHistory::get()->filter('Created:LessThan', date('Y-m-d H:i:s', strtotime('-'.self::config()->expires_days.' days')));
        if($records->count()>0) {
            foreach($records as $record) {
                $record->delete();
            }
        }
    }
protected function onAfterWrite() {
        parent::onAfterWrite();
        
        $records=KapostConversionHistory::get()->filter('Created:LessThan', date('Y-m-d H:i:s', strtotime('-'.self::config()->expires_days.' days')));
        if($records->count()>0) {
            foreach($records as $record) {
                $record->delete();
            }
        }
    }
protected function onAfterWrite ( ) { parent :: onAfterWrite ( ) ; $ records = KapostConversionHistory :: get ( ) -> filter ( 'Created:LessThan' , date ( 'Y-m-d H:i:s' , strtotime ( '-' . self :: config ( ) -> expires_days . ' days' ) ) ) ; if ( $ records -> count ( ) > 0 ) { foreach ( $ records as $ record ) { $ record -> delete ( ) ; } } }
Cleans up the conversion history records after X days, after writing to the database where X is defined in the config
Cleans up the conversion history records after X days after writing to the database where X is defined in the config