Skip to content

Commit 9646168

Browse files
TD-6282: Dashborad and notification optimization
1 parent abb1816 commit 9646168

File tree

44 files changed

+316
-36
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+316
-36
lines changed

AdminUI/LearningHub.Nhs.AdminUI/LearningHub.Nhs.AdminUI.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
<PackageReference Include="HtmlSanitizer" Version="6.0.453" />
9090
<PackageReference Include="IdentityModel" Version="4.6.0" />
9191
<PackageReference Include="LearningHub.Nhs.Caching" Version="2.0.2" />
92-
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.48" />
92+
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.58" />
9393
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.19.0" />
9494
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="6.0.36" />
9595
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.36" />

LearningHub.Nhs.WebUI.AutomatedUiTests/LearningHub.Nhs.WebUI.AutomatedUiTests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
<ItemGroup>
1414
<PackageReference Include="FluentAssertions" Version="6.12.0" />
15+
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.58" />
1516
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.1.13" />
1617
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
1718
<PackageReference Include="Selenium.Axe" Version="4.0.19" />

LearningHub.Nhs.WebUI/LearningHub.Nhs.WebUI.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
<PackageReference Include="HtmlAgilityPack" Version="1.11.72" />
114114
<PackageReference Include="IdentityModel" Version="4.6.0" />
115115
<PackageReference Include="LearningHub.Nhs.Caching" Version="2.0.0" />
116-
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.48" />
116+
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.58" />
117117
<PackageReference Include="linqtotwitter" Version="6.9.0" />
118118
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.19.0" />
119119
<PackageReference Include="Microsoft.ApplicationInsights.EventCounterCollector" Version="2.21.0" />

OpenAPI/LearningHub.Nhs.OpenApi.Models/LearningHub.Nhs.OpenApi.Models.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
</PropertyGroup>
1717

1818
<ItemGroup>
19-
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.48" />
19+
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.58" />
2020
<PackageReference Include="NLog.Web.AspNetCore" Version="4.15.0" />
2121
</ItemGroup>
2222

OpenAPI/LearningHub.Nhs.OpenApi.Repositories.Interface/LearningHub.Nhs.OpenApi.Repositories.Interface.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
</PropertyGroup>
1818

1919
<ItemGroup>
20+
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.58" />
2021
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.7" />
2122
</ItemGroup>
2223

OpenAPI/LearningHub.Nhs.OpenApi.Repositories/EntityFramework/LearningHubDbContext.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ namespace LearningHub.Nhs.OpenApi.Repositories.EntityFramework
1515
using LearningHub.Nhs.Models.Hierarchy;
1616
using LearningHub.Nhs.Models.Messaging;
1717
using LearningHub.Nhs.Models.MyLearning;
18+
using LearningHub.Nhs.Models.Notification;
1819
using LearningHub.Nhs.Models.Resource;
1920
using LearningHub.Nhs.Models.Resource.ResourceDisplay;
2021
using LearningHub.Nhs.Models.User;
@@ -124,6 +125,11 @@ public LearningHubDbContextOptions Options
124125
/// </summary>
125126
public virtual DbSet<Notification> Notification { get; set; }
126127

128+
/// <summary>
129+
/// Gets or sets the Notification Count.
130+
/// </summary>
131+
public virtual DbSet<NotificationCount> NotificationCount { get; set; }
132+
127133
/// <summary>
128134
/// Gets or sets the user notification..
129135
/// </summary>

OpenAPI/LearningHub.Nhs.OpenApi.Repositories/LearningHub.Nhs.OpenApi.Repositories.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<PackageReference Include="AutoMapper" Version="10.1.1" />
2525
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.1" />
2626
<PackageReference Include="IdentityModel" Version="4.6.0" />
27+
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.58" />
2728
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.20" />
2829
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.20" />
2930
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.20" />

OpenAPI/LearningHub.Nhs.OpenApi.Repositories/Repositories/UserNotificationRepository.cs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
namespace LearningHub.Nhs.OpenApi.Repositories.Repositories
22
{
33
using System;
4+
using System.Data;
45
using System.Linq;
56
using System.Threading.Tasks;
67
using LearningHub.Nhs.Models.Entities;
78
using LearningHub.Nhs.Models.Enums;
89
using LearningHub.Nhs.OpenApi.Repositories.EntityFramework;
910
using LearningHub.Nhs.OpenApi.Repositories.Interface.Repositories;
11+
using Microsoft.Data.SqlClient;
1012
using Microsoft.EntityFrameworkCore;
1113

1214
/// <summary>
@@ -42,9 +44,23 @@ public async Task<UserNotification> GetByIdAsync(int id)
4244
/// <returns>The <see cref="Task"/>.</returns>
4345
public async Task<int> GetUserUnreadNotificationCountAsync(int userId)
4446
{
45-
return await GetActiveNotifications(userId, DateTimeOffset.Now)
46-
.Where(n => !n.UserNotification.ReadOnDate.HasValue)
47-
.CountAsync();
47+
try
48+
{
49+
var param0 = new SqlParameter("@p0", SqlDbType.Int) { Value = userId };
50+
var param1 = new SqlParameter("@p1", SqlDbType.Int) { Value = this.TimezoneOffsetManager.UserTimezoneOffset ?? (object)DBNull.Value };
51+
52+
var result = await this.DbContext
53+
.NotificationCount
54+
.FromSqlRaw("EXEC hub.GetActiveNotificationCount @p0, @p1", param0, param1)
55+
.ToListAsync();
56+
57+
return result.FirstOrDefault()?.UserNotificationCount ?? 0;
58+
}
59+
catch (Exception ex)
60+
{
61+
// Optional: log ex
62+
throw new Exception("Failed to get unread notification count: " + ex.Message);
63+
}
4864
}
4965

5066
/// <summary>

OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/LearningHub.Nhs.OpenApi.Services.Interface.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
<ItemGroup>
1919
<PackageReference Include="elfhHub.Nhs.Models" Version="3.0.9" />
20-
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.48" />
20+
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.58" />
2121
</ItemGroup>
2222

2323
<ItemGroup>

OpenAPI/LearningHub.Nhs.OpenApi.Services.Interface/Services/IResourceService.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,13 @@ Task<AssessmentProgressViewModel> GetAssessmentProgress(
415415
/// <returns>The <see cref="Task{LearningHubValidationResult}"/>.</returns>
416416
Task<LearningHubValidationResult> CreateResourceVersionValidationResultAsync(ResourceVersionValidationResultViewModel validationResultViewModel);
417417

418+
/// <summary>
419+
/// The get resource header view model async.
420+
/// </summary>
421+
/// <param name="resourceReferenceId">The resourceReferenceId<see cref="int"/>.</param>
422+
/// <returns>The <see cref="Task{ResourceHeaderViewModel}"/>.</returns>
423+
Task<ResourceHeaderViewModel> GetResourceHeaderViewModelAsync(int resourceReferenceId);
424+
418425
/// <summary>
419426
/// The set resource type.
420427
/// </summary>

0 commit comments

Comments
 (0)