202 views

Description

Performance Degradation of On-Call Calendar where roster_schedule_spans exceeds 1000 records

Steps to Reproduce

 An On-Call rota that has a lot of Time Off, Extra Time, or Cover records in the past will notice a loading time performance degradation if these past records are not deleted.

Workaround

Reduce the amount of past roster_schedule_span records. (Please note that this will mean that past: Extra Rota Time, User Assigned Coverage and Time Off records will no longer appear). Once the roster_schedule_span records exceeds 1000s per rota the performance may become degraded.

Run the following in Scripts - Background:

// Change the utcDate to a date that roster span records with end dates prior to it will be deleted
var utcDate = "2016-01-02 00:00:00";
deleteRosterSpansById(getRosterSpanIdsBeforeDate(utcDate));

function getRosterSpanIdsBeforeDate(utcDate) {
    var gdt = new GlideDateTime();
    gdt.setValueUTC(utcDate, "yyyy-MM-dd HH:mm:ss");
    var utcMillis = gdt.getNumericValue();

    var rosterSchedSpansSysIds = [];
    var gr = new GlideRecord("roster_schedule_span");
    gr.query();
    while (gr.next()) {
       var sdt = new GlideScheduleDateTime();
       sdt.setValue(gr.end_date_time);
       if (sdt.getMS() < utcMillis && gr.repeat_type == "")
          rosterSchedSpansSysIds.push(gr.getValue("sys_id"));
    }
    return rosterSchedSpansSysIds;
}

function deleteRosterSpansById(rosterSchedSpansSysIds) {
    var gr = new GlideRecord("roster_schedule_span");
    // Disables the running of business rules that might normally be triggered by subsequent actions
    gr.setWorkflow(false);
    gr.addQuery("sys_id", "IN", rosterSchedSpansSysIds);
    gr.query();
    gr.deleteMultiple();
}

 

 


Related Problem: PRB668746

Seen In

Eureka Patch 11 Hot Fix 2
Fuji Patch 11
Helsinki Patch 6 Hot Fix 1

Associated Community Threads

There is no data to report.

Article Information

Last Updated:2018-05-02 11:58:59
Published:2016-09-06