use of com.redhat.cloud.notifications.models.CronJobRun in project notifications-backend by RedHatInsights.
the class DailyEmailAggregationJob method processAggregateEmails.
List<AggregationCommand> processAggregateEmails(LocalDateTime endTime, CollectorRegistry registry) {
final CronJobRun lastCronJobRun = emailAggregationResources.getLastCronJobRun();
LocalDateTime startTime = lastCronJobRun.getLastRun();
LOG.infof("Collecting email aggregation for period (%s, %s) and type %s", startTime, endTime, DAILY);
final List<AggregationCommand> pendingAggregationCommands = emailAggregationResources.getApplicationsWithPendingAggregation(startTime, endTime).stream().map(aggregationKey -> new AggregationCommand(aggregationKey, startTime, endTime, DAILY)).collect(Collectors.toList());
LOG.infof("Finished collecting email aggregations for period (%s, %s) and type %s after %d seconds. %d (accountIds, applications) pairs were processed", startTime, endTime, DAILY, SECONDS.between(endTime, LocalDateTime.now(UTC)), pendingAggregationCommands.size());
pairsProcessed = Gauge.build().name("aggregator_job_accountid_application_pairs_processed").help("Number of accountId and application pairs processed.").register(registry);
pairsProcessed.set(pendingAggregationCommands.size());
return pendingAggregationCommands;
}
Aggregations