mirror of
https://github.com/C9Glax/tranga.git
synced 2025-05-22 06:03:01 +02:00
Update Jobs on each cycle (since it is super fast now)
This commit is contained in:
parent
d6e945741a
commit
8e0c964883
@ -105,20 +105,16 @@ public static class Tranga
|
|||||||
IServiceProvider serviceProvider = (IServiceProvider)serviceProviderObj;
|
IServiceProvider serviceProvider = (IServiceProvider)serviceProviderObj;
|
||||||
using IServiceScope scope = serviceProvider.CreateScope();
|
using IServiceScope scope = serviceProvider.CreateScope();
|
||||||
PgsqlContext context = scope.ServiceProvider.GetRequiredService<PgsqlContext>();
|
PgsqlContext context = scope.ServiceProvider.GetRequiredService<PgsqlContext>();
|
||||||
|
|
||||||
DateTime lastContextUpdate = DateTime.UnixEpoch;
|
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if (lastContextUpdate.AddMilliseconds(TrangaSettings.startNewJobTimeoutMs * 10) < DateTime.UtcNow)
|
Log.Info("Loading Jobs...");
|
||||||
{
|
DateTime loadStart = DateTime.UtcNow;
|
||||||
Log.Info("Loading Jobs...");
|
context.Jobs.Load();
|
||||||
context.Jobs.Load();
|
Log.Info("Updating Entries...");
|
||||||
lastContextUpdate = DateTime.UtcNow;
|
|
||||||
Log.Info("Jobs Loaded!");
|
|
||||||
}
|
|
||||||
foreach (EntityEntry entityEntry in context.ChangeTracker.Entries().ToArray())
|
foreach (EntityEntry entityEntry in context.ChangeTracker.Entries().ToArray())
|
||||||
entityEntry.Reload();
|
entityEntry.Reload();
|
||||||
|
Log.Info($"Jobs Loaded! (took {DateTime.UtcNow.Subtract(loadStart).TotalMilliseconds}ms)");
|
||||||
//Update finished Jobs to new states
|
//Update finished Jobs to new states
|
||||||
List<Job> completedJobs = context.Jobs.Local.Where(j => j.state == JobState.Completed).ToList();
|
List<Job> completedJobs = context.Jobs.Local.Where(j => j.state == JobState.Completed).ToList();
|
||||||
foreach (Job completedJob in completedJobs)
|
foreach (Job completedJob in completedJobs)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user