public function execute() {
        global $CFG, $DB;

        if (!empty($CFG->gradehistorylifetime)) {
            $now = time();
            $histlifetime = $now - ($CFG->gradehistorylifetime * DAYSECS);
            $tables = [
                'grade_outcomes_history',
                'grade_categories_history',
                'grade_items_history',
                'grade_grades_history',
                'scale_history'
            ];
            foreach ($tables as $table) {
                if ($DB->delete_records_select($table, "timemodified < ?", [$histlifetime])) {
                    mtrace("    Deleted old grade history records from '$table'");
                }
            }
        }
    }
public function execute() {
        global $CFG, $DB;

        if (!empty($CFG->gradehistorylifetime)) {
            $now = time();
            $histlifetime = $now - ($CFG->gradehistorylifetime * DAYSECS);
            $tables = [
                'grade_outcomes_history',
                'grade_categories_history',
                'grade_items_history',
                'grade_grades_history',
                'scale_history'
            ];
            foreach ($tables as $table) {
                if ($DB->delete_records_select($table, "timemodified < ?", [$histlifetime])) {
                    mtrace("    Deleted old grade history records from '$table'");
                }
            }
        }
    }
public function execute ( ) { global $ CFG , $ DB ; if ( ! empty ( $ CFG -> gradehistorylifetime ) ) { $ now = time ( ) ; $ histlifetime = $ now - ( $ CFG -> gradehistorylifetime * DAYSECS ) ; $ tables = [ 'grade_outcomes_history' , 'grade_categories_history' , 'grade_items_history' , 'grade_grades_history' , 'scale_history' ] ; foreach ( $ tables as $ table ) { if ( $ DB -> delete_records_select ( $ table , "timemodified < ?" , [ $ histlifetime ] ) ) { mtrace ( "    Deleted old grade history records from '$table'" ) ; } } } }
Cleanup history tables.
Cleanup history tables .