override public void Run() { var(channelId, uploadsListId) = ApiDataFetcher.FetchChannelInfo(DataService); var videos = DbReader.GetVideos(); videos.AsParallel() .WithDegreeOfParallelism(DegreeOfParallelism) .ForAll(video => DbWriter.Write(ApiDataFetcher.FetchDailyMetrics(AnalyticsService, channelId, video, Logger))); }
override public void Run() { var(channelId, uploadsListId) = ApiDataFetcher.FetchChannelInfo(DataService); var comparison = DbReader.CompareVideoLifetimeDailyTotal(); long comparisonMinLimit = 500; double comparisonThreshold = 0.05; foreach (var item in comparison) { if (item.Lifetime > 0) { var ratio = Math.Abs((double)item.Lifetime - item.Total) / ((double)item.Lifetime); if (Math.Abs(ratio) > comparisonThreshold && item.Lifetime > comparisonMinLimit) { Logger.Information("Reprocessing video {0}: daily views {1} from {4} to {5}, lifetime views {2} at {6} and ratio {3}" , item.Id.VideoId, item.Total, item.Lifetime, ratio, item.DailyStart, item.DailyEnd, item.LifetimeDate); DbWriter.Write(ApiDataFetcher.FetchDailyMetrics(AnalyticsService, channelId, item.Id, Logger, true)); } } } }