File tree Expand file tree Collapse file tree 8 files changed +19
-22
lines changed
Expand file tree Collapse file tree 8 files changed +19
-22
lines changed Original file line number Diff line number Diff line change 11using fim_queueing_admin . Models ;
22using Microsoft . EntityFrameworkCore ;
3- using Microsoft . EntityFrameworkCore . Storage . ValueConversion ;
43
54namespace fim_queueing_admin . Data ;
65
Original file line number Diff line number Diff line change @@ -87,9 +87,8 @@ public async Task GetStreamInfo()
8787
8888 private async Task SendPendingAlertsToCaller ( )
8989 {
90- // var pendingAlerts = await dbContext.AlertCarts.Where(ac => ac.CartId == CartId && ac.ReadTime == null)
91- // .Select(ac => ac.Alert).ToListAsync();
92- var pendingAlerts = new List < Alert > ( ) ;
90+ var pendingAlerts = await dbContext . AlertCarts . Where ( ac => ac . CartId == CartId && ac . ReadTime == null )
91+ . Select ( ac => ac . Alert ) . ToListAsync ( ) ;
9392
9493 await Clients . Caller . SendAsync ( "PendingAlerts" , pendingAlerts ) ;
9594 }
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ public class AlertEntityTypeConfiguration : IEntityTypeConfiguration<Alert>
2020 public void Configure ( EntityTypeBuilder < Alert > builder )
2121 {
2222 builder
23+ . ToTable ( "alerts" , "temp" )
2324 . HasMany ( a => a . AlertCarts )
2425 . WithOne ( ac => ac . Alert ) ;
2526 }
Original file line number Diff line number Diff line change @@ -19,6 +19,8 @@ public class AlertCartEntityTypeConfiguration : IEntityTypeConfiguration<AlertCa
1919{
2020 public void Configure ( EntityTypeBuilder < AlertCart > builder )
2121 {
22- builder . HasKey ( nameof ( AlertCart . AlertId ) , nameof ( AlertCart . CartId ) ) ;
22+ builder
23+ . ToTable ( "alert_carts" , "temp" )
24+ . HasKey ( nameof ( AlertCart . AlertId ) , nameof ( AlertCart . CartId ) ) ;
2325 }
2426}
Original file line number Diff line number Diff line change @@ -9,8 +9,7 @@ public class Cart : BaseEquipment
99{
1010 public AvCartConfiguration ? Configuration { get ; set ; } = new ( ) ;
1111
12- // TODO: This is not yet implemented in Postgres
13- // public ICollection<AlertCart>? AlertCarts { get; set; }
12+ public ICollection < AlertCart > ? AlertCarts { get ; set ; }
1413
1514 public class AvCartConfiguration
1615 {
@@ -25,9 +24,9 @@ public class CartEntityTypeConfiguration : BaseEquipmentEntityTypeConfiguration<
2524{
2625 protected override void ConfigureEntity ( EntityTypeBuilder < Cart > builder )
2726 {
28- // builder
29- // .HasMany(a => a.AlertCarts)
30- // .WithOne(ac => ac.Cart);
27+ builder
28+ . HasMany ( a => a . AlertCarts )
29+ . WithOne ( ac => ac . Cart ) ;
3130 builder . HasQueryFilter ( c => c . EquipmentType == EquipmentType . AvCart ) ;
3231 builder . OwnsOne ( c => c . Configuration , d =>
3332 {
Original file line number Diff line number Diff line change @@ -171,7 +171,7 @@ async Task<string> GetAccessToken()
171171 } ) ;
172172}
173173
174- builder . Services . AddHostedService < DatabaseKeepAliveService > ( ) ;
174+ // builder.Services.AddHostedService<DatabaseKeepAliveService>();
175175
176176builder . Services . AddCors ( opt =>
177177{
Original file line number Diff line number Diff line change @@ -18,9 +18,8 @@ public async Task SendPendingAlertsToEveryone()
1818 var hubContext = serviceProvider . GetRequiredService < IHubContext < AssistantHub > > ( ) ;
1919 var dbContext = serviceProvider . GetRequiredService < FimDbContext > ( ) ;
2020
21- // var pendingAlerts = await dbContext.AlertCarts.Where(ac => ac.ReadTime == null)
22- // .GroupBy(k => k.CartId, v => v.Alert).ToListAsync();
23- var pendingAlerts = new List < IGrouping < Guid , Alert > > ( ) ;
21+ var pendingAlerts = await dbContext . AlertCarts . Where ( ac => ac . ReadTime == null )
22+ . GroupBy ( k => k . CartId , v => v . Alert ) . ToListAsync ( ) ;
2423
2524 foreach ( var group in pendingAlerts )
2625 {
Original file line number Diff line number Diff line change 1212 </div >
1313 <div ><a asp-action =" Manage" >Create Alert</a ></div >
1414 @{
15- var alerts = new List <Alert >();
16- // TODO: Implement alerts in postgres
17- // var alerts = await DbContext.Alerts.OrderByDescending(c => c.CreatedAt).Select(a => new
18- // {
19- // a.Id,
20- // Content = a.Content.Substring(0, 50),
21- // a.CreatedAt
22- // }).ToListAsync();
15+ var alerts = await DbContext .Alerts .OrderByDescending (c => c .CreatedAt ).Select (a => new
16+ {
17+ a .Id ,
18+ Content = a .Content .Substring (0 , 50 ),
19+ a .CreatedAt
20+ }).ToListAsync ();
2321 }
2422 @if (! alerts .Any ())
2523 {
You can’t perform that action at this time.
0 commit comments