Exemple #1
0
        private static DateTime?GetStartingDate(string startDate, IOverallStoreManager overallStoreManager)
        {
            DateTime?possibleStartingDate = null;

            if (string.IsNullOrEmpty(startDate))
            {
                possibleStartingDate = overallStoreManager.NextStartingDate();
            }
            else
            {
                possibleStartingDate = startDate.ToDate();
            }

            return(possibleStartingDate);
        }
 public EntriesService(ILogger <EntriesService> logger,
                       IStoreManager storeManager,
                       IOverallStoreManager overallStoreManager,
                       IMap <DateTimeInterval, TimeInterval> mapDateTimeIntervalToTimeInterval,
                       IMap <IEnumerable <TopItem>, IEnumerable <EntryTimeLine> > mapTopItemsToEntryTimeLines,
                       IMap <IEnumerable <TopItemWithPartitionKey>, IEnumerable <OverallEntry> > mapTopItemsWithPartitionKeyToOverallEntries,
                       IMapAggregateTwoEntries <IEnumerable <TopItemWithPartitionKey>, IEnumerable <TopItemWithPartitionKey>, IEnumerable <OverallEntryEvolution> > mapTopItemsWithPartitionKeyToOverallEntriesEvolution,
                       IMapAggregateTwoEntries <IEnumerable <TopItem>, IEnumerable <TopItem>, IEnumerable <DayEntryEvolution> > mapTopItemsToDayEntriesEvolution)
 {
     this.logger              = logger;
     this.storeManager        = storeManager;
     this.overallStoreManager = overallStoreManager;
     this.mapDateTimeIntervalToTimeInterval                    = mapDateTimeIntervalToTimeInterval;
     this.mapTopItemsToEntryTimeLines                          = mapTopItemsToEntryTimeLines;
     this.mapTopItemsWithPartitionKeyToOverallEntries          = mapTopItemsWithPartitionKeyToOverallEntries;
     this.mapTopItemsWithPartitionKeyToOverallEntriesEvolution = mapTopItemsWithPartitionKeyToOverallEntriesEvolution;
     this.mapTopItemsToDayEntriesEvolution                     = mapTopItemsToDayEntriesEvolution;
 }
Exemple #3
0
        private static void CalculateAndStoreTodayItems(
            ILogger <Program> logger,
            ServiceProvider serviceProvider,
            List <TopItem> todayTopItems,
            IStoreManager dailyStoreManager,
            IOverallStoreManager overallStoreManager)
        {
            logger.LogInformation("Calculating scores for today's items...");
            CalculateDailyTopItems(logger, serviceProvider, todayTopItems);
            var todaysProcessedItems = overallStoreManager.AdvanceOverallItems(todayTopItems.FirstOrDefault().Date, todayTopItems.ToArray(), out int totalRecordsAffectedForTheDay);

            logger.LogInformation("Items processed: {0}", totalRecordsAffectedForTheDay);
            try
            {
                dailyStoreManager.UpdateItems(todaysProcessedItems);
            }
            catch (Exception e)
            {
                logger.LogError(e, "Cannot persist items in store.");
                throw;
            }
        }