From dece32e3615656d5ac76f2edd9da032c6452d274 Mon Sep 17 00:00:00 2001
From: Aryadev Chavali <aryadevchavali1@gmail.com>
Date: Sat, 2 Mar 2019 01:45:24 +0000
Subject: Using dependency injection and scoped services, can setup aggregator
 job to run without config

---
 Main/Startup.cs | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/Main/Startup.cs b/Main/Startup.cs
index 980e110..c077b6b 100644
--- a/Main/Startup.cs
+++ b/Main/Startup.cs
@@ -32,11 +32,13 @@ namespace Main {
                 options.UseMySQL(Configuration.GetConnectionString("Storage"));
             });
 
+            services.AddScoped<IAggregatorJob, AggregatorJob>();
+
             services.AddHangfire(options => options.UseStorage(new MySqlStorage(Configuration.GetConnectionString("Storage"))));
             services.AddDirectoryBrowser();
         }
 
-        public void Configure(IApplicationBuilder app, IHostingEnvironment env) {
+        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IAggregatorJob aggregator) {
             if (env.IsDevelopment()) {
                 app.UseDeveloperExceptionPage();
             }
@@ -51,10 +53,7 @@ namespace Main {
             app.UseHangfireServer();
             app.UseHangfireDashboard();
 
-            RecurringJob.AddOrUpdate<AggregatorJob>(
-                x => x.Start(Configuration.GetConnectionString("Aggregator")),
-                Cron.HourInterval(3)
-            );
+            RecurringJob.AddOrUpdate("aggregator", () => aggregator.Start(), Cron.HourInterval(3));
         }
     }
 }
-- 
cgit v1.2.3-13-gbd6f