private void ReadStats(WorkflowStats stats, WorkflowDbContext dbc) { stats.Count = dbc.KeyReleaseWorkflowStates.Count(); stats.Expired = dbc.KeyReleaseWorkflowStates.Count(x => x.ValidUntil < _Dtp.Snapshot); stats.Unauthorised = dbc.KeyReleaseWorkflowStates.Count(x => x.ValidUntil < _Dtp.Snapshot && x.LabConfirmationId != null && x.AuthorisedByCaregiver == null && x.DateOfSymptomsOnset == null); stats.Authorised = dbc.KeyReleaseWorkflowStates.Count(x => x.ValidUntil < _Dtp.Snapshot && x.LabConfirmationId == null && x.AuthorisedByCaregiver != null && x.DateOfSymptomsOnset != null); stats.AuthorisedAndFullyPublished = dbc.KeyReleaseWorkflowStates.Count(x => x.ValidUntil < _Dtp.Snapshot && x.AuthorisedByCaregiver != null && x.DateOfSymptomsOnset != null && x.LabConfirmationId == null && x.Teks.Count(y => y.PublishingState == PublishingState.Unpublished) == 0); stats.TekCount = dbc.TemporaryExposureKeys.Count(); stats.TekPublished = dbc.TemporaryExposureKeys.Count(x => x.PublishingState == PublishingState.Published); stats.TekUnpublished = dbc.TemporaryExposureKeys.Count(x => x.PublishingState == PublishingState.Unpublished); }
private void Log(WorkflowStats stats, string message) { var sb = new StringBuilder(message); sb.AppendLine(); sb.AppendLine($"{nameof(WorkflowStats.Count)}:{stats.Count}"); sb.AppendLine($"{nameof(WorkflowStats.Expired)}:{stats.Expired}"); sb.AppendLine("of which:"); sb.AppendLine($" Unauthorised:{stats.Unauthorised}"); sb.AppendLine($" Authorised:{stats.Authorised}"); sb.AppendLine(" of which:"); sb.AppendLine($" FullyPublished:{stats.AuthorisedAndFullyPublished}"); sb.AppendLine(); sb.AppendLine($"{nameof(WorkflowStats.TekCount)}:{stats.TekPublished}"); sb.AppendLine("of which:"); sb.AppendLine($" Published:{stats.TekPublished}"); sb.AppendLine($" Unpublished:{stats.TekUnpublished}"); _Logger.LogInformation(sb.ToString()); }