From 005da7fbcbf0004d30277216c0aed375833f29ae Mon Sep 17 00:00:00 2001 From: ig Date: Tue, 4 Apr 2023 10:39:42 +0200 Subject: [PATCH] Subscribe Cleanup on TaskPoolScheduler, should make Backend startup faster --- csharp/App/Backend/Database/Db.cs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/csharp/App/Backend/Database/Db.cs b/csharp/App/Backend/Database/Db.cs index e9cb827ca..d9d5ae1cd 100644 --- a/csharp/App/Backend/Database/Db.cs +++ b/csharp/App/Backend/Database/Db.cs @@ -16,20 +16,21 @@ public static partial class Db private static SQLiteConnection Connection { get; } = new SQLiteConnection(DbPath); - public static TableQuery Sessions => Connection.Table(); - public static TableQuery Folders => Connection.Table(); - public static TableQuery DeletedFolders => Connection.Table(); - public static TableQuery Installations => Connection.Table(); - public static TableQuery DeletedInstallations => Connection.Table(); - public static TableQuery Users => Connection.Table(); - public static TableQuery DeletedUsers => Connection.Table(); - public static TableQuery FolderAccess => Connection.Table(); - public static TableQuery InstallationAccess => Connection.Table(); - public static TableQuery OrderNumber2Installation => Connection.Table(); - + public static TableQuery Sessions => Connection.Table(); + public static TableQuery Folders => Connection.Table(); + public static TableQuery Installations => Connection.Table(); + public static TableQuery Users => Connection.Table(); + public static TableQuery FolderAccess => Connection.Table(); + public static TableQuery InstallationAccess => Connection.Table(); + public static TableQuery OrderNumber2Installation => Connection.Table(); + + public static TableQuery DeletedInstallations => Connection.Table(); + public static TableQuery DeletedUsers => Connection.Table(); + public static TableQuery DeletedFolders => Connection.Table(); public static void Init() { + // used to force static constructor } @@ -54,6 +55,7 @@ public static partial class Db Observable.Interval(TimeSpan.FromDays(0.5)) .StartWith(0) // Do it right away (on startup) .ObserveOn(TaskPoolScheduler.Default) + .SubscribeOn(TaskPoolScheduler.Default) .SelectMany(Cleanup) .Subscribe(); }