aboutsummaryrefslogtreecommitdiff
path: root/Main/Jobs/AggregatorJob.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Main/Jobs/AggregatorJob.cs')
-rw-r--r--Main/Jobs/AggregatorJob.cs21
1 files changed, 13 insertions, 8 deletions
diff --git a/Main/Jobs/AggregatorJob.cs b/Main/Jobs/AggregatorJob.cs
index 065a1f0..6773ea3 100644
--- a/Main/Jobs/AggregatorJob.cs
+++ b/Main/Jobs/AggregatorJob.cs
@@ -10,7 +10,16 @@ using Database;
using Aggregator;
namespace Main.Jobs {
- public class AggregatorJob {
+ public interface IAggregatorJob {
+ Task Start();
+ }
+
+ public class AggregatorJob : IAggregatorJob {
+ private DatabaseContext Context;
+ public AggregatorJob(DatabaseContext context) {
+ Context = context;
+ }
+
private static List<Config> configs = new List<Config> {
new Config {
Source = "BBC",
@@ -44,13 +53,9 @@ namespace Main.Jobs {
"https://abcnews.go.com/abcnews/topstories"
};
- public async Task Start(string config) {
- var builder = new DbContextOptionsBuilder<DatabaseContext>();
- builder.UseMySQL(config);
- using (var context = new DatabaseContext(builder.Options)) {
- var articles = await parseMultiple();
- await context.InsertArticles(articles);
- }
+ public async Task Start() {
+ var articles = await parseMultiple();
+ await Context.InsertArticles(articles);
}
private async Task<List<Article>> parseMultiple() {