Run CleanUp on TaskPool

This commit is contained in:
ig 2023-03-21 11:40:23 +01:00
parent 28a0ef5530
commit e25de16f65
1 changed files with 8 additions and 6 deletions

View File

@ -1,3 +1,4 @@
using System.Reactive.Concurrency;
using System.Reactive.Linq; using System.Reactive.Linq;
using InnovEnergy.App.Backend.DataTypes; using InnovEnergy.App.Backend.DataTypes;
using InnovEnergy.App.Backend.DataTypes.Methods; using InnovEnergy.App.Backend.DataTypes.Methods;
@ -15,10 +16,10 @@ public static partial class Db
private static SQLiteConnection Connection { get; } = new SQLiteConnection(DbPath); private static SQLiteConnection Connection { get; } = new SQLiteConnection(DbPath);
public static TableQuery<Session> Sessions => Connection.Table<Session>(); public static TableQuery<Session> Sessions => Connection.Table<Session>();
public static TableQuery<Folder> Folders => Connection.Table<Folder>(); public static TableQuery<Folder> Folders => Connection.Table<Folder>();
public static TableQuery<Installation> Installations => Connection.Table<Installation>(); public static TableQuery<Installation> Installations => Connection.Table<Installation>();
public static TableQuery<User> Users => Connection.Table<User>(); public static TableQuery<User> Users => Connection.Table<User>();
public static TableQuery<FolderAccess> FolderAccess => Connection.Table<FolderAccess>(); public static TableQuery<FolderAccess> FolderAccess => Connection.Table<FolderAccess>();
public static TableQuery<InstallationAccess> InstallationAccess => Connection.Table<InstallationAccess>(); public static TableQuery<InstallationAccess> InstallationAccess => Connection.Table<InstallationAccess>();
@ -38,9 +39,10 @@ public static partial class Db
}); });
Observable.Interval(TimeSpan.FromDays(0.5)) Observable.Interval(TimeSpan.FromDays(0.5))
.StartWith(0) // Do it right away (on startup) .StartWith(0) // Do it right away (on startup)
.ObserveOn(TaskPoolScheduler.Default)
.SelectMany(Cleanup) .SelectMany(Cleanup)
.Subscribe(); // and then daily .Subscribe();
} }