Skip to content

B: Check-in Manager Performance Issue #4

@nateh777

Description

@nateh777

The following code needs to be optimized:

foreach ( DateTime chartTime in chartTimes )
{
// Get the active schedules
foreach ( var schedule in schedules )
{
if ( schedule.WasScheduleOrCheckInActive( chartTime ) )
{
ActiveScheduleIds.Add( schedule.Id );
var currentAttendance = new AttendanceService( rockContext )
.Queryable().AsNoTracking()
.Where( a =>
a.StartDateTime > minDate &&
!a.EndDateTime.HasValue &&
a.Occurrence.LocationId.HasValue &&
a.PersonAlias != null &&
a.DidAttend.HasValue &&
a.DidAttend.Value &&
a.Occurrence.ScheduleId.HasValue &&
a.Occurrence.ScheduleId == schedule.Id )
.ToList();
if ( currentAttendance.Any() )
{
foreach ( var attendance in currentAttendance )
{
if ( attendance.Occurrence.LocationId.HasValue && !occurrences.Any( o => o.Id == attendance.OccurrenceId ) )
{
occurrences.Add( attendance.Occurrence );
}
}
}
}
}
}

A client experienced performance issues from said code. Differences of 14-33 second load times down to 0.5-2 seconds with this code removed.

If we are unable to optimize, we need to confirm what is all affected by this code, give the users a setting to disable it, and display appropriate warnings if/as it causes incorrect data to display.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions