Skip to content

Commit

Permalink
Merge pull request #1108 from publichealthengland/NTBS-2074
Browse files Browse the repository at this point in the history
NTBS-2074: Fix sentry warnings from .NET upgrade
  • Loading branch information
LeoCie committed Mar 16, 2021
2 parents 34f618e + 6d18c9a commit 5ea83c1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
4 changes: 3 additions & 1 deletion ntbs-service/DataAccess/DataQualityRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,9 @@ private IQueryable<Notification> 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();
}
}
}
10 changes: 8 additions & 2 deletions ntbs-service/DataAccess/NotificationRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -295,6 +296,8 @@ public async Task<IEnumerable<Notification>> 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 =>
{
Expand Down Expand Up @@ -329,6 +332,7 @@ public async Task<NotificationGroup> GetNotificationGroupAsync(int notificationI
.Include(g => g.Notifications)
.ThenInclude(n => n.HospitalDetails)
.ThenInclude(e => e.CaseManager)
.OrderBy(n => n.NotificationGroupId)
.AsSplitQuery()
.SingleOrDefaultAsync();
}
Expand All @@ -344,7 +348,7 @@ private IQueryable<Notification> 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.
Expand All @@ -358,7 +362,9 @@ private IQueryable<Notification> 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<Notification> GetBaseNotificationsIQueryable()
Expand Down
4 changes: 2 additions & 2 deletions ntbs-service/Helpers/SessionStateHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
12 changes: 6 additions & 6 deletions ntbs-service/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ActivityDetectionMiddleware>();
Expand All @@ -591,6 +585,12 @@ Making this conditional is the result of serilog not playing nicely with WebAppl
app.UseMiddleware<AuditGetRequestMiddleWare>();
}

app.UseEndpoints(endpoints =>
{
endpoints.MapRazorPages();
endpoints.MapControllers();
});

ConfigureHangfire(app);

var cultureInfo = new CultureInfo("en-GB");
Expand Down

0 comments on commit 5ea83c1

Please sign in to comment.