public async Task <IActionResult> Get( [FromServices] IConfiguration configuration, [FromServices] LastChangedListContext lastChangedListContext, CancellationToken cancellationToken) { var maxErrorCount = configuration.GetValue <int?>("Caches:LastChangedList:MaxErrorCount") ?? 10; var maxErrorTimeInSeconds = configuration.GetValue <int?>("Caches:LastChangedList:MaxErrorTimeInSeconds") ?? 60; var maxErrorTime = DateTimeOffset.UtcNow.AddSeconds(-1 * maxErrorTimeInSeconds); var numberOfRecords = await lastChangedListContext .LastChangedList .OrderBy(x => x.Id) .Where(r => r.Position > r.LastPopulatedPosition && r.ErrorCount < maxErrorCount && (r.LastError == null || r.LastError < maxErrorTime)) .CountAsync(cancellationToken); return(Ok(new[] { new { name = "LastChangedList", numberOfRecordsToProcess = numberOfRecords } })); }
protected GivenThreeUnpopulatedRecordsInDb(LastChangedListContext context) { context.LastChangedList.AddRange(Records); context.SaveChanges(); Context = context; }
protected GivenTwoErrorRecordsInDb(LastChangedListContext context) { context.LastChangedList.AddRange(Records); context.SaveChanges(); Context = context; }
protected GivenOnePopulatedRecord(LastChangedListContext context) { context.LastChangedList.AddRange(Records); context.SaveChanges(); Context = context; }
public Repository(LastChangedListContext context) => _context = context;
public Repository(LastChangedListContext context, int commandTimeoutInSeconds) { _context = context; _context.Database.SetCommandTimeout(commandTimeoutInSeconds); }
public FakeRepository(LastChangedListContext context) => _repository = new Repository(context);