diff --git a/src/FilterLists.Services/DependencyInjection/Extensions/ConfigureServicesCollection.cs b/src/FilterLists.Services/DependencyInjection/Extensions/ConfigureServicesCollection.cs index 769134cb7..ee93937d8 100644 --- a/src/FilterLists.Services/DependencyInjection/Extensions/ConfigureServicesCollection.cs +++ b/src/FilterLists.Services/DependencyInjection/Extensions/ConfigureServicesCollection.cs @@ -33,7 +33,6 @@ public static void AddFilterListsAgentServices(this IServiceCollection services, o.UseMySql(config.GetConnectionString("FilterListsConnection"), m => m.MigrationsAssembly("FilterLists.Api"))); services.TryAddScoped(); - services.TryAddSingleton(); services.AddAutoMapper(); } } diff --git a/src/FilterLists.Services/Snapshot/Snapshot.cs b/src/FilterLists.Services/Snapshot/Snapshot.cs index 7f9d2acdf..e2857cf11 100644 --- a/src/FilterLists.Services/Snapshot/Snapshot.cs +++ b/src/FilterLists.Services/Snapshot/Snapshot.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Net; using System.Net.Http; -using System.Text; using System.Threading.Tasks; using FilterLists.Data; using FilterLists.Data.Entities.Junctions; @@ -18,14 +17,12 @@ public class Snapshot { private const int BatchSize = 1000; private readonly FilterListsDbContext dbContext; - private readonly EmailService emailService; private readonly FilterListViewUrlDto list; private readonly Data.Entities.Snapshot snapEntity; - public Snapshot(FilterListsDbContext dbContext, EmailService emailService, FilterListViewUrlDto list) + public Snapshot(FilterListsDbContext dbContext, FilterListViewUrlDto list) { this.dbContext = dbContext; - this.emailService = emailService; this.list = list; snapEntity = new Data.Entities.Snapshot { @@ -42,10 +39,10 @@ public async Task TrySaveAsync() { await SaveAsync(); } - catch (Exception e) + catch (Exception) { //allow other snapshots to continue - await SendExceptionEmail(e); + //TODO: log } } @@ -158,17 +155,5 @@ private async Task SetSuccessful() snapEntity.WasSuccessful = true; await dbContext.SaveChangesAsync(); } - - private async Task SendExceptionEmail(Exception e) - { - var msg = new StringBuilder(); - msg.AppendLine("FilterListId: " + list.Id); - msg.AppendLine("Exception:"); - msg.AppendLine(e.Message); - msg.AppendLine(e.StackTrace); - msg.AppendLine(e.InnerException?.Message); - msg.AppendLine(e.InnerException?.StackTrace); - await emailService.SendEmailAsync("Snapshot Exception", msg.ToString()); - } } } \ No newline at end of file diff --git a/src/FilterLists.Services/Snapshot/SnapshotService.cs b/src/FilterLists.Services/Snapshot/SnapshotService.cs index b77d7eb6a..35e062a5a 100644 --- a/src/FilterLists.Services/Snapshot/SnapshotService.cs +++ b/src/FilterLists.Services/Snapshot/SnapshotService.cs @@ -12,12 +12,12 @@ namespace FilterLists.Services.Snapshot { public class SnapshotService : Service { - private readonly EmailService emailService; private readonly DateTime yesterday = DateTime.UtcNow.AddDays(-1); - public SnapshotService(FilterListsDbContext dbContext, IConfigurationProvider mapConfig, - EmailService emailService) - : base(dbContext, mapConfig) => this.emailService = emailService; + public SnapshotService(FilterListsDbContext dbContext, IConfigurationProvider mapConfig) + : base(dbContext, mapConfig) + { + } public async Task CaptureAsync(int batchSize) { @@ -45,7 +45,7 @@ await DbContext .ToListAsync(); private IEnumerable CreateSnapshots(IEnumerable lists) => - lists.Select(l => new Snapshot(DbContext, emailService, l)); + lists.Select(l => new Snapshot(DbContext, l)); private static async Task SaveSnapshots(IEnumerable snapshots) {