public async Task <(EntryItem[], bool)> GetBatchToIndex(int i, int batchSize) { var batch = await ClientHelper.PolledRequests(() => Enumerable.Range(i, batchSize).Select(n => _entryClient.Get(n, tolerate404: true)).ToArray(), _logger); var items = batch .Where(x => x != null && x.Exists) .Select(y => new EntryItem { Id = y.Id, TeamName = y.TeamName, RealName = y.PlayerFullName }).ToArray(); if (!items.Any()) { _currentConsecutiveCountOfMissingEntries += batchSize; } else { _currentConsecutiveCountOfMissingEntries = 0; } // There are large "gaps" of missing entries (deleted ones, perhaps). The indexing job needs to work its way past these gaps, but still stop when // we think that there are none left to index var couldBeMore = _currentConsecutiveCountOfMissingEntries < _options.ConsecutiveCountOfMissingLeaguesBeforeStoppingIndexJob; if (!couldBeMore) { if (_options.ResetIndexingBookmarkWhenDone) { await _indexBookmarkProvider.SetBookmark(1); } else { var resetBookmarkTo = i - _options.ConsecutiveCountOfMissingLeaguesBeforeStoppingIndexJob; await _indexBookmarkProvider.SetBookmark(resetBookmarkTo > 1?resetBookmarkTo : 1); } } else if (_bookmarkCounter > 50) // Set a bookmark at every 50th batch { await _indexBookmarkProvider.SetBookmark(i + batchSize); _bookmarkCounter = 0; } else { _bookmarkCounter++; } return(items, couldBeMore); }
public async Task <IActionResult> OnPostChangeEntryIndexingBookmark(ChangeBookmarkModel model) { await _entryIndexBookmarkProvider.SetBookmark(model.Bookmark); TempData["msg"] += "Entry bookmark updated"; return(RedirectToPage("Indexing")); }