public async Task StartJob() { var appProperties = await _applicationPropertyDao.GetAsync(); var startDate = appProperties?.LastMongoIndexing ?? DateTime.MinValue; await IndexAnswers(startDate); await IndexQuestions(startDate); await _applicationPropertyDao.UpsertPropertyAsync(app => app.LastMongoIndexing, DateTime.UtcNow); }
private async void UploadBatch(ContentResponse response) { if (response.Results.Count == 0) { return; } var request = new ConfluenceElasticUpsertRequest { Entities = CreateSearchablePages(response.Results) }; await _elasticsearchClient.UpsertManyAsync(request); LogUploadedBatch(request); await _applicationPropertyDao.UpsertPropertyAsync(p => p.ConfluenceJobLastUpdate, GetLastDate(response)); }
public async Task StartJob() { var appProperties = await _applicationPropertyDao.GetAsync(); var loadFromDate = appProperties?.JiraJobLastUpdate ?? DateTime.MinValue; var loadFromDateLocal = loadFromDate.ToLocalTime(); var isAllIssuesUpdated = false; var startAt = 0; while (!isAllIssuesUpdated) { var jiraResponse = await _jiraClient.GetLatestIssuesAsync(_settings.Value.ProjectNames, loadFromDateLocal, _settings.Value.BatchSize, startAt); await UploadIssuesBatch(jiraResponse); var lastIssueDateTimeUpdated = jiraResponse.Last().Updated; if (lastIssueDateTimeUpdated.HasValue) { var loadFromDateTimeLocalFormat = loadFromDateLocal.ToString(TimeFormat, CultureInfo.InvariantCulture); var lastIssueDateTimeUpdatedFormat = lastIssueDateTimeUpdated.Value.ToString(TimeFormat, CultureInfo.InvariantCulture); if (loadFromDateTimeLocalFormat == lastIssueDateTimeUpdatedFormat) { startAt += _settings.Value.BatchSize; } else { startAt = 0; loadFromDateLocal = lastIssueDateTimeUpdated.Value; } await _applicationPropertyDao.UpsertPropertyAsync(p => p.JiraJobLastUpdate, loadFromDateLocal.ToUniversalTime()); } isAllIssuesUpdated = jiraResponse.TotalItems == jiraResponse.Count(); } }