public async Task NotifySubscribersIfApplicable(params Guid[] releaseIds) { var releasesToNotify = _context.Releases .Include(r => r.ReleaseStatuses) .Where(r => releaseIds.Contains(r.Id)) .ToList() .Where(r => r.NotifySubscribers) .ToList(); var messages = await releasesToNotify .ToAsyncEnumerable() .SelectAwait(async release => await BuildPublicationNotificationMessage(release)) .ToListAsync(); if (messages.Count > 0) { await _storageQueueService.AddMessages(ReleaseNotificationQueue, messages); releasesToNotify .ForEach(release => { var status = release.ReleaseStatuses .OrderBy(rs => rs.Created) .Last(); _context.Update(status); status.NotifiedOn = DateTime.UtcNow; }); await _context.SaveChangesAsync(); } }
// ReSharper disable once UnusedMember.Global public async Task RestartImports( [QueueTrigger(RestartImportsQueue)] RestartImportsMessage message, ExecutionContext executionContext, ILogger logger) { logger.LogInformation($"{executionContext.FunctionName} triggered: {message}"); var incompleteImports = await _contentDbContext.DataImports .AsQueryable() .Where(import => IncompleteStatuses.Contains(import.Status)) .ToListAsync(); var messages = incompleteImports .Select(import => new ImportMessage(import.Id)) .ToList(); await _storageQueueService.AddMessages(ImportsPendingQueue, messages); logger.LogInformation($"{executionContext.FunctionName} completed"); }
public async Task NotifySubscribers(params Guid[] releaseIds) { var publications = GetPublications(releaseIds); var messages = publications.Select(BuildPublicationNotificationMessage); await _storageQueueService.AddMessages(PublicationQueue, messages); }