mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
Revert "re=add emailed exceptions to snapshot service"
This reverts commit 0ab62db0fd.
This commit is contained in:
parent
58e9c98413
commit
1706aebe19
3 changed files with 8 additions and 24 deletions
|
|
@ -33,7 +33,6 @@ public static void AddFilterListsAgentServices(this IServiceCollection services,
|
|||
o.UseMySql(config.GetConnectionString("FilterListsConnection"),
|
||||
m => m.MigrationsAssembly("FilterLists.Api")));
|
||||
services.TryAddScoped<SnapshotService>();
|
||||
services.TryAddSingleton<EmailService>();
|
||||
services.AddAutoMapper();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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<Snapshot> CreateSnapshots(IEnumerable<FilterListViewUrlDto> lists) =>
|
||||
lists.Select(l => new Snapshot(DbContext, emailService, l));
|
||||
lists.Select(l => new Snapshot(DbContext, l));
|
||||
|
||||
private static async Task SaveSnapshots(IEnumerable<Snapshot> snapshots)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue