コード例 #1
0
        override public void Run()
        {
            var(channelId, uploadsListId) = ApiDataFetcher.FetchChannelInfo(DataService);
            var videoIds        = ApiDataFetcher.FetchVideoIds(DataService, uploadsListId).ToList();
            var videoProperties = ApiDataFetcher.FetchVideoProperties(DataService, videoIds);

            DbWriter.Write(videoProperties.Select(x => Api2DbObjectConverter.ConvertVideo(x)), channelId, Logger);
        }
コード例 #2
0
        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)));
        }
コード例 #3
0
        override public void Run()
        {
            var(channelId, uploadsListId) = ApiDataFetcher.FetchChannelInfo(DataService);
            var playlists           = ApiDataFetcher.FetchPlaylists(DataService, channelId);
            var playlistsVideoIds   = ApiDataFetcher.FetchVideoIdsInPlaylists(DataService, playlists);
            var playlistsWithVideos = playlists.Zip(playlistsVideoIds, (playlist, videoIds) => new { playlist, videoIds });

            DbWriter.Write(playlistsWithVideos.Select(x => Api2DbObjectConverter.ConvertPlaylist(x.playlist, x.videoIds)), Logger);
        }
コード例 #4
0
        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));
                    }
                }
            }
        }