File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -68,6 +68,13 @@ public async Task ScheduleHydrationAsync(CancellationToken cancellationToken)
6868
6969 var agent = await processorContext . Agents . FirstOrDefaultAsync ( cancellationToken ) ;
7070
71+ if ( string . IsNullOrWhiteSpace ( agent . Uid ) )
72+ {
73+ var logger = scope . ServiceProvider . GetRequiredService < ILogger < HydrationService > > ( ) ;
74+ logger . LogWarning ( "Agent UID is not set. Cannot schedule hydration." ) ;
75+ return ;
76+ }
77+
7178 if ( agent . ScheduledScrapingIntervalMinutes == null )
7279 {
7380 RecurringJob . RemoveIfExists ( agent . Uid ) ;
Original file line number Diff line number Diff line change @@ -84,6 +84,15 @@ public void ConfigureServices(IServiceCollection services)
8484 using ( var context = new ProcessorContext ( processorOptionsBuilder . Options ) )
8585 {
8686 context . Database . Migrate ( ) ;
87+ var agent = context . Agents . FirstOrDefault ( ) ;
88+
89+ if ( agent == null )
90+ {
91+ agent = new Data . Agent ( ) ;
92+
93+ context . Agents . Add ( agent ) ;
94+ context . SaveChanges ( ) ;
95+ }
8796 }
8897
8998 var optionsBuilder = new DbContextOptionsBuilder < UsersContext > ( ) ;
@@ -202,7 +211,7 @@ public void ConfigureServices(IServiceCollection services)
202211
203212 services . AddSingleton < WebPushNotificationProducer > ( ) ;
204213 services . AddSingleton < IHostedService > ( p => p . GetService < WebPushNotificationProducer > ( ) ) ;
205-
214+
206215 services . AddSingleton < WebsocketClientOrganizer > ( ) ;
207216 services . AddSingleton < IHostedService > ( p => p . GetService < WebsocketClientOrganizer > ( ) ) ;
208217
You can’t perform that action at this time.
0 commit comments