diff --git a/ntbs-service/DataAccess/DataQualityRepository.cs b/ntbs-service/DataAccess/DataQualityRepository.cs index 29ffcc1ad..f762bf559 100644 --- a/ntbs-service/DataAccess/DataQualityRepository.cs +++ b/ntbs-service/DataAccess/DataQualityRepository.cs @@ -352,7 +352,9 @@ private IQueryable GetBaseNotificationQueryableWithoutAlertWithTyp && n.NotificationStatus != NotificationStatus.Deleted && n.NotificationStatus != NotificationStatus.Denotified) // And make sure it doesn't have this type of alert already - .Where(n => !n.Alerts.Any(a => a is T)); + .Where(n => !n.Alerts.Any(a => a is T)) + .OrderBy(n => n.NotificationId) + .AsSplitQuery(); } } } diff --git a/ntbs-service/DataAccess/NotificationRepository.cs b/ntbs-service/DataAccess/NotificationRepository.cs index 1a300dc4e..8137b59ab 100644 --- a/ntbs-service/DataAccess/NotificationRepository.cs +++ b/ntbs-service/DataAccess/NotificationRepository.cs @@ -4,6 +4,7 @@ using System.Threading.Tasks; using EFAuditer; using Microsoft.EntityFrameworkCore; +using MoreLinq; using ntbs_service.Models; using ntbs_service.Models.Entities; using ntbs_service.Models.Enums; @@ -295,6 +296,8 @@ public async Task> GetInactiveNotificationsToCloseAsyn .ThenInclude(t => t.TreatmentOutcome) .Where(n => n.NotificationStatus == NotificationStatus.Notified) .Where(n => n.TreatmentEvents.Any(t => t.TreatmentOutcome != null)) + .OrderBy(n => n.NotificationId) + .AsSplitQuery() .ToListAsync()) .Where(n => { @@ -329,6 +332,7 @@ public async Task GetNotificationGroupAsync(int notificationI .Include(g => g.Notifications) .ThenInclude(n => n.HospitalDetails) .ThenInclude(e => e.CaseManager) + .OrderBy(n => n.NotificationGroupId) .AsSplitQuery() .SingleOrDefaultAsync(); } @@ -344,7 +348,7 @@ private IQueryable GetBannerReadyNotificationsIQueryable() .Include(n => n.SocialContextVenues) .Include(n => n.TreatmentEvents) .ThenInclude(t => t.TreatmentOutcome) - .AsSplitQuery(); + .OrderBy(n => n.NotificationId); } // Gets Notification model with basic information for use in notifications homepage lists. @@ -358,7 +362,9 @@ private IQueryable GetNotificationsWithBasicInformationIQueryable( .ThenInclude(la => la.LocalAuthorityToPHEC) .ThenInclude(pl => pl.PHEC) .Include(n => n.HospitalDetails.TBService.PHEC) - .Include(n => n.HospitalDetails.CaseManager); + .Include(n => n.HospitalDetails.CaseManager) + .OrderBy(n => n.NotificationId) + .AsSplitQuery(); } public IQueryable GetBaseNotificationsIQueryable() diff --git a/ntbs-service/Helpers/SessionStateHelper.cs b/ntbs-service/Helpers/SessionStateHelper.cs index 60da50934..8dcc8faa9 100644 --- a/ntbs-service/Helpers/SessionStateHelper.cs +++ b/ntbs-service/Helpers/SessionStateHelper.cs @@ -12,8 +12,8 @@ public static void UpdateSessionActivity(ISession session) public static bool IsUpdatedRecently(ISession session) { - var date = DateTime.Parse(session.GetString("LastActivityTimestamp")); - return date.AddMinutes(30) > DateTime.Now; + var activityTimestamp = session.GetString("LastActivityTimestamp"); + return activityTimestamp != null && DateTime.Parse(activityTimestamp).AddMinutes(30) > DateTime.Now; } } } diff --git a/ntbs-service/Startup.cs b/ntbs-service/Startup.cs index f60495f2f..223b0a457 100644 --- a/ntbs-service/Startup.cs +++ b/ntbs-service/Startup.cs @@ -575,12 +575,6 @@ Making this conditional is the result of serilog not playing nicely with WebAppl app.UseCookiePolicy(); app.UseSession(); - app.UseEndpoints(endpoints => - { - endpoints.MapRazorPages(); - endpoints.MapControllers(); - }); - if (!Env.IsEnvironment("CI")) { app.UseMiddleware(); @@ -591,6 +585,12 @@ Making this conditional is the result of serilog not playing nicely with WebAppl app.UseMiddleware(); } + app.UseEndpoints(endpoints => + { + endpoints.MapRazorPages(); + endpoints.MapControllers(); + }); + ConfigureHangfire(app); var cultureInfo = new CultureInfo("en-GB");