From c184ec2d983a3b307e052f9a3e1f15b5a4e51e93 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Tue, 3 Sep 2013 22:01:28 -0700 Subject: [PATCH] Progress messages are logged with Logger.Progress --- NzbDrone.Api/Indexers/ReleaseModule.cs | 14 ++-- .../Instrumentation/LoggerExtensions.cs | 29 ++++++--- .../DecisionEngine/DownloadDecisionMaker.cs | 21 ++++-- NzbDrone.Core/Download/DownloadService.cs | 3 +- .../SingleEpisodeSearchCriteria.cs | 2 +- .../IndexerSearch/EpisodeSearchService.cs | 15 ++++- .../IndexerSearch/NzbSearchService.cs | 6 +- .../IndexerSearch/SeasonSearchService.cs | 14 +++- .../IndexerSearch/SeriesSearchService.cs | 13 +++- NzbDrone.Core/Indexers/IndexerFetchService.cs | 8 +-- NzbDrone.Core/Indexers/RssSyncService.cs | 6 +- NzbDrone.Core/MediaFiles/DiskScanService.cs | 4 ++ .../MediaFiles/RenameEpisodeFileService.cs | 9 +-- .../ProgressMessageTarget.cs | 7 +- NzbDrone.Core/Tv/EpisodeService.cs | 2 +- NzbDrone.Core/Tv/RefreshEpisodeService.cs | 2 +- NzbDrone.Core/Tv/RefreshSeriesService.cs | 64 ++++++++++--------- UI/Episode/Search/Layout.js | 7 +- .../ProgressMessageCollection.js | 8 ++- UI/Shared/Actioneer.js | 20 ++++-- 20 files changed, 165 insertions(+), 89 deletions(-) diff --git a/NzbDrone.Api/Indexers/ReleaseModule.cs b/NzbDrone.Api/Indexers/ReleaseModule.cs index aaf452261..28d104ffa 100644 --- a/NzbDrone.Api/Indexers/ReleaseModule.cs +++ b/NzbDrone.Api/Indexers/ReleaseModule.cs @@ -1,6 +1,8 @@ using System.Collections.Generic; using Nancy; +using NLog; using NzbDrone.Api.Mapping; +using NzbDrone.Common.Instrumentation; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Download; using NzbDrone.Core.IndexerSearch; @@ -21,18 +23,21 @@ namespace NzbDrone.Api.Indexers private readonly IMakeDownloadDecision _downloadDecisionMaker; private readonly IDownloadService _downloadService; private readonly IParsingService _parsingService; + private readonly Logger _logger; public ReleaseModule(IFetchAndParseRss rssFetcherAndParser, - ISearchForNzb nzbSearchService, - IMakeDownloadDecision downloadDecisionMaker, - IDownloadService downloadService, - IParsingService parsingService) + ISearchForNzb nzbSearchService, + IMakeDownloadDecision downloadDecisionMaker, + IDownloadService downloadService, + IParsingService parsingService, + Logger logger) { _rssFetcherAndParser = rssFetcherAndParser; _nzbSearchService = nzbSearchService; _downloadDecisionMaker = downloadDecisionMaker; _downloadService = downloadService; _parsingService = parsingService; + _logger = logger; GetResourceAll = GetReleases; Post["/"] = x=> DownloadRelease(this.Bind()); } @@ -60,6 +65,7 @@ namespace NzbDrone.Api.Indexers private List GetEpisodeReleases(int episodeId) { var decisions = _nzbSearchService.EpisodeSearch(episodeId); + return MapDecisions(decisions); } diff --git a/NzbDrone.Common/Instrumentation/LoggerExtensions.cs b/NzbDrone.Common/Instrumentation/LoggerExtensions.cs index 9816965c7..305b3f610 100644 --- a/NzbDrone.Common/Instrumentation/LoggerExtensions.cs +++ b/NzbDrone.Common/Instrumentation/LoggerExtensions.cs @@ -9,12 +9,20 @@ namespace NzbDrone.Common.Instrumentation { public static class LoggerExtensions { - public static void Complete(this Logger logger, string message) + public static void Progress(this Logger logger, string message) { - var logEvent = new LogEventInfo(LogLevel.Info, logger.Name, message); - logEvent.Properties.Add("Status", ProcessState.Completed); + LogProgressMessage(logger, message, ProcessState.Running); + } - logger.Log(logEvent); + public static void Progress(this Logger logger, string message, params object[] args) + { + var formattedMessage = String.Format(message, args); + Progress(logger, formattedMessage); + } + + public static void Complete(this Logger logger, string message) + { + LogProgressMessage(logger, message, ProcessState.Completed); } public static void Complete(this Logger logger, string message, params object[] args) @@ -25,10 +33,7 @@ namespace NzbDrone.Common.Instrumentation public static void Failed(this Logger logger, string message) { - var logEvent = new LogEventInfo(LogLevel.Info, logger.Name, message); - logEvent.Properties.Add("Status", ProcessState.Failed); - - logger.Log(logEvent); + LogProgressMessage(logger, message, ProcessState.Failed); } public static void Failed(this Logger logger, string message, params object[] args) @@ -36,5 +41,13 @@ namespace NzbDrone.Common.Instrumentation var formattedMessage = String.Format(message, args); Failed(logger, formattedMessage); } + + private static void LogProgressMessage(Logger logger, string message, ProcessState state) + { + var logEvent = new LogEventInfo(LogLevel.Info, logger.Name, message); + logEvent.Properties.Add("Status", state); + + logger.Log(logEvent); + } } } diff --git a/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs b/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs index d94036901..0dbc66f7d 100644 --- a/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs +++ b/NzbDrone.Core/DecisionEngine/DownloadDecisionMaker.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; using NLog; +using NzbDrone.Common.Instrumentation; using NzbDrone.Core.DecisionEngine.Specifications.Search; using NzbDrone.Core.IndexerSearch.Definitions; using NzbDrone.Core.Parser; @@ -12,8 +13,8 @@ namespace NzbDrone.Core.DecisionEngine { public interface IMakeDownloadDecision { - List GetRssDecision(IEnumerable reports); - List GetSearchDecision(IEnumerable reports, SearchCriteriaBase searchCriteriaBase); + List GetRssDecision(List reports); + List GetSearchDecision(List reports, SearchCriteriaBase searchCriteriaBase); } public class DownloadDecisionMaker : IMakeDownloadDecision @@ -29,18 +30,28 @@ namespace NzbDrone.Core.DecisionEngine _logger = logger; } - public List GetRssDecision(IEnumerable reports) + public List GetRssDecision(List reports) { return GetDecisions(reports).ToList(); } - public List GetSearchDecision(IEnumerable reports, SearchCriteriaBase searchCriteriaBase) + public List GetSearchDecision(List reports, SearchCriteriaBase searchCriteriaBase) { return GetDecisions(reports, searchCriteriaBase).ToList(); } - private IEnumerable GetDecisions(IEnumerable reports, SearchCriteriaBase searchCriteria = null) + private IEnumerable GetDecisions(List reports, SearchCriteriaBase searchCriteria = null) { + if (reports.Any()) + { + _logger.Progress("Processing {0} reports", reports.Count()); + } + + else + { + _logger.Progress("No reports found"); + } + foreach (var report in reports) { DownloadDecision decision = null; diff --git a/NzbDrone.Core/Download/DownloadService.cs b/NzbDrone.Core/Download/DownloadService.cs index 583fdfa1f..2c3d15f5c 100644 --- a/NzbDrone.Core/Download/DownloadService.cs +++ b/NzbDrone.Core/Download/DownloadService.cs @@ -1,4 +1,5 @@ using NLog; +using NzbDrone.Common.Instrumentation; using NzbDrone.Common.Messaging; using NzbDrone.Core.Parser.Model; @@ -37,7 +38,7 @@ namespace NzbDrone.Core.Download downloadClient.DownloadNzb(remoteEpisode); - _logger.Info("Report sent to download client. {0}", downloadTitle); + _logger.Progress("Report sent to download client. {0}", downloadTitle); _messageAggregator.PublishEvent(new EpisodeGrabbedEvent(remoteEpisode)); } } diff --git a/NzbDrone.Core/IndexerSearch/Definitions/SingleEpisodeSearchCriteria.cs b/NzbDrone.Core/IndexerSearch/Definitions/SingleEpisodeSearchCriteria.cs index 371f66bc6..56d110079 100644 --- a/NzbDrone.Core/IndexerSearch/Definitions/SingleEpisodeSearchCriteria.cs +++ b/NzbDrone.Core/IndexerSearch/Definitions/SingleEpisodeSearchCriteria.cs @@ -7,7 +7,7 @@ namespace NzbDrone.Core.IndexerSearch.Definitions public override string ToString() { - return string.Format("[{0} : S{1:00}E{2:00} ]", SceneTitle, SeasonNumber, EpisodeNumber); + return string.Format("[{0} : S{1:00}E{2:00}]", SceneTitle, SeasonNumber, EpisodeNumber); } } } \ No newline at end of file diff --git a/NzbDrone.Core/IndexerSearch/EpisodeSearchService.cs b/NzbDrone.Core/IndexerSearch/EpisodeSearchService.cs index e62a99836..476178f36 100644 --- a/NzbDrone.Core/IndexerSearch/EpisodeSearchService.cs +++ b/NzbDrone.Core/IndexerSearch/EpisodeSearchService.cs @@ -1,4 +1,7 @@ -using NzbDrone.Common.Messaging; +using System.Linq; +using NLog; +using NzbDrone.Common.Instrumentation; +using NzbDrone.Common.Messaging; using NzbDrone.Core.Download; namespace NzbDrone.Core.IndexerSearch @@ -7,17 +10,23 @@ namespace NzbDrone.Core.IndexerSearch { private readonly ISearchForNzb _nzbSearchService; private readonly IDownloadApprovedReports _downloadApprovedReports; + private readonly Logger _logger; - public EpisodeSearchService(ISearchForNzb nzbSearchService, IDownloadApprovedReports downloadApprovedReports) + public EpisodeSearchService(ISearchForNzb nzbSearchService, + IDownloadApprovedReports downloadApprovedReports, + Logger logger) { _nzbSearchService = nzbSearchService; _downloadApprovedReports = downloadApprovedReports; + _logger = logger; } public void Execute(EpisodeSearchCommand message) { var decisions = _nzbSearchService.EpisodeSearch(message.EpisodeId); - _downloadApprovedReports.DownloadApproved(decisions); + var downloaded = _downloadApprovedReports.DownloadApproved(decisions); + + _logger.Complete("Episode search completed. {0} reports downloaded.", downloaded.Count); } } } diff --git a/NzbDrone.Core/IndexerSearch/NzbSearchService.cs b/NzbDrone.Core/IndexerSearch/NzbSearchService.cs index 7386341d2..b17d9ea55 100644 --- a/NzbDrone.Core/IndexerSearch/NzbSearchService.cs +++ b/NzbDrone.Core/IndexerSearch/NzbSearchService.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Globalization; using System.Threading.Tasks; using NLog; +using NzbDrone.Common.Instrumentation; using NzbDrone.Core.DataAugmentation.Scene; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.IndexerSearch.Definitions; @@ -129,9 +130,10 @@ namespace NzbDrone.Core.IndexerSearch private List Dispatch(Func> searchAction, SearchCriteriaBase criteriaBase) { var indexers = _indexerService.GetAvailableIndexers().ToList(); - var reports = new List(); + _logger.Progress("Searching {0} indexers for {1}", indexers.Count, criteriaBase); + var reports = new List(); var taskList = new List(); var taskFactory = new TaskFactory(TaskCreationOptions.LongRunning, TaskContinuationOptions.None); @@ -159,7 +161,7 @@ namespace NzbDrone.Core.IndexerSearch Task.WaitAll(taskList.ToArray()); - _logger.Debug("Total of {0} reports were found for {1} in {2} indexers", reports.Count, criteriaBase, indexers.Count); + _logger.Debug("Total of {0} reports were found for {1} from {2} indexers", reports.Count, criteriaBase, indexers.Count); return _makeDownloadDecision.GetSearchDecision(reports, criteriaBase).ToList(); } diff --git a/NzbDrone.Core/IndexerSearch/SeasonSearchService.cs b/NzbDrone.Core/IndexerSearch/SeasonSearchService.cs index 7572b5b6d..f1a7a1e71 100644 --- a/NzbDrone.Core/IndexerSearch/SeasonSearchService.cs +++ b/NzbDrone.Core/IndexerSearch/SeasonSearchService.cs @@ -1,4 +1,6 @@ -using NzbDrone.Common.Messaging; +using NLog; +using NzbDrone.Common.Instrumentation; +using NzbDrone.Common.Messaging; using NzbDrone.Core.Download; namespace NzbDrone.Core.IndexerSearch @@ -7,17 +9,23 @@ namespace NzbDrone.Core.IndexerSearch { private readonly ISearchForNzb _nzbSearchService; private readonly IDownloadApprovedReports _downloadApprovedReports; + private readonly Logger _logger; - public SeasonSearchService(ISearchForNzb nzbSearchService, IDownloadApprovedReports downloadApprovedReports) + public SeasonSearchService(ISearchForNzb nzbSearchService, + IDownloadApprovedReports downloadApprovedReports, + Logger logger) { _nzbSearchService = nzbSearchService; _downloadApprovedReports = downloadApprovedReports; + _logger = logger; } public void Execute(SeasonSearchCommand message) { var decisions = _nzbSearchService.SeasonSearch(message.SeriesId, message.SeasonNumber); - _downloadApprovedReports.DownloadApproved(decisions); + var downloaded = _downloadApprovedReports.DownloadApproved(decisions); + + _logger.Complete("Season search completed. {0} reports downloaded.", downloaded.Count); } } } diff --git a/NzbDrone.Core/IndexerSearch/SeriesSearchService.cs b/NzbDrone.Core/IndexerSearch/SeriesSearchService.cs index 89dd7c6c2..14da8c84d 100644 --- a/NzbDrone.Core/IndexerSearch/SeriesSearchService.cs +++ b/NzbDrone.Core/IndexerSearch/SeriesSearchService.cs @@ -1,4 +1,6 @@ using System.Linq; +using NLog; +using NzbDrone.Common.Instrumentation; using NzbDrone.Common.Messaging; using NzbDrone.Core.Download; using NzbDrone.Core.Tv; @@ -10,14 +12,17 @@ namespace NzbDrone.Core.IndexerSearch private readonly ISeasonService _seasonService; private readonly ISearchForNzb _nzbSearchService; private readonly IDownloadApprovedReports _downloadApprovedReports; + private readonly Logger _logger; public SeriesSearchService(ISeasonService seasonService, ISearchForNzb nzbSearchService, - IDownloadApprovedReports downloadApprovedReports) + IDownloadApprovedReports downloadApprovedReports, + Logger logger) { _seasonService = seasonService; _nzbSearchService = nzbSearchService; _downloadApprovedReports = downloadApprovedReports; + _logger = logger; } public void Execute(SeriesSearchCommand message) @@ -27,11 +32,15 @@ namespace NzbDrone.Core.IndexerSearch .OrderBy(s => s.SeasonNumber) .ToList(); + var downloadedCount = 0; + foreach (var season in seasons) { var decisions = _nzbSearchService.SeasonSearch(message.SeriesId, season.SeasonNumber); - _downloadApprovedReports.DownloadApproved(decisions); + downloadedCount += _downloadApprovedReports.DownloadApproved(decisions).Count; } + + _logger.Complete("Series search completed. {0} reports downloaded.", downloadedCount); } } } diff --git a/NzbDrone.Core/Indexers/IndexerFetchService.cs b/NzbDrone.Core/Indexers/IndexerFetchService.cs index 2e585f862..cc0eb8691 100644 --- a/NzbDrone.Core/Indexers/IndexerFetchService.cs +++ b/NzbDrone.Core/Indexers/IndexerFetchService.cs @@ -48,7 +48,7 @@ namespace NzbDrone.Core.Indexers var result = Fetch(indexer, searchCriteria, 0).DistinctBy(c => c.NzbUrl).ToList(); - _logger.Info("Finished searching {0} on {1}. Found {2}", indexer.Name, searchCriteria, result.Count); + _logger.Info("Finished searching {0} for {1}. Found {2}", indexer.Name, searchCriteria, result.Count); return result; } @@ -80,12 +80,10 @@ namespace NzbDrone.Core.Indexers var result = Fetch(indexer, searchUrls); - _logger.Info("Finished searching {0} on {1}. Found {2}", indexer.Name, searchCriteria, result.Count); + _logger.Info("Finished searching {0} for {1}. Found {2}", indexer.Name, searchCriteria, result.Count); return result; - } - public IList Fetch(IIndexer indexer, DailyEpisodeSearchCriteria searchCriteria) { _logger.Debug("Searching for {0}", searchCriteria); @@ -93,7 +91,7 @@ namespace NzbDrone.Core.Indexers var searchUrls = indexer.GetDailyEpisodeSearchUrls(searchCriteria.QueryTitle, searchCriteria.SeriesTvRageId, searchCriteria.Airtime); var result = Fetch(indexer, searchUrls); - _logger.Info("Finished searching {0} on {1}. Found {2}", indexer.Name, searchCriteria, result.Count); + _logger.Info("Finished searching {0} for {1}. Found {2}", indexer.Name, searchCriteria, result.Count); return result; } diff --git a/NzbDrone.Core/Indexers/RssSyncService.cs b/NzbDrone.Core/Indexers/RssSyncService.cs index dcbf340b1..3362bcc56 100644 --- a/NzbDrone.Core/Indexers/RssSyncService.cs +++ b/NzbDrone.Core/Indexers/RssSyncService.cs @@ -33,13 +33,13 @@ namespace NzbDrone.Core.Indexers public void Sync() { - _logger.Info("Starting RSS Sync"); + _logger.Progress("Starting RSS Sync"); var reports = _rssFetcherAndParser.Fetch(); var decisions = _downloadDecisionMaker.GetRssDecision(reports); - var qualifiedReports = _downloadApprovedReports.DownloadApproved(decisions); + var downloaded = _downloadApprovedReports.DownloadApproved(decisions); - _logger.Complete("RSS Sync Completed. Reports found: {0}, Reports downloaded: {1}", reports.Count, qualifiedReports.Count()); + _logger.Complete("RSS Sync Completed. Reports found: {0}, Reports downloaded: {1}", reports.Count, downloaded.Count()); } public void Execute(RssSyncCommand message) diff --git a/NzbDrone.Core/MediaFiles/DiskScanService.cs b/NzbDrone.Core/MediaFiles/DiskScanService.cs index 0fb6901fe..fc5aade8e 100644 --- a/NzbDrone.Core/MediaFiles/DiskScanService.cs +++ b/NzbDrone.Core/MediaFiles/DiskScanService.cs @@ -3,6 +3,7 @@ using System.IO; using System.Linq; using NLog; using NzbDrone.Common; +using NzbDrone.Common.Instrumentation; using NzbDrone.Common.Messaging; using NzbDrone.Core.MediaFiles.Commands; using NzbDrone.Core.MediaFiles.EpisodeImport; @@ -52,6 +53,7 @@ namespace NzbDrone.Core.MediaFiles private void Scan(Series series) { + _logger.Progress("Starting disk scan for {0}", series.Title); _messageAggregator.PublishCommand(new CleanMediaFileDb(series.Id)); if (!_diskProvider.FolderExists(series.Path)) @@ -64,6 +66,8 @@ namespace NzbDrone.Core.MediaFiles var decisions = _importDecisionMaker.GetImportDecisions(mediaFileList, series, false); _importApprovedEpisodes.Import(decisions); + + _logger.Complete("Completed disk scan for {0}", series.Title); } public string[] GetVideoFiles(string path, bool allDirectories = true) diff --git a/NzbDrone.Core/MediaFiles/RenameEpisodeFileService.cs b/NzbDrone.Core/MediaFiles/RenameEpisodeFileService.cs index 7912039e7..5a3dc563e 100644 --- a/NzbDrone.Core/MediaFiles/RenameEpisodeFileService.cs +++ b/NzbDrone.Core/MediaFiles/RenameEpisodeFileService.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using NLog; +using NzbDrone.Common.Instrumentation; using NzbDrone.Common.Messaging; using NzbDrone.Core.MediaFiles.Commands; using NzbDrone.Core.MediaFiles.Events; @@ -67,9 +68,9 @@ namespace NzbDrone.Core.MediaFiles var series = _seriesService.GetSeries(message.SeriesId); var episodeFiles = _mediaFileService.GetFilesBySeason(message.SeriesId, message.SeasonNumber); - _logger.Info("Renaming {0} files for {1} season {2}", episodeFiles.Count, series.Title, message.SeasonNumber); + _logger.Progress("Renaming {0} files for {1} season {2}", episodeFiles.Count, series.Title, message.SeasonNumber); RenameFiles(episodeFiles, series); - _logger.Debug("Episode Fies renamed for {0} season {1}", series.Title, message.SeasonNumber); + _logger.Complete("Episode Fies renamed for {0} season {1}", series.Title, message.SeasonNumber); } public void Execute(RenameSeriesCommand message) @@ -77,9 +78,9 @@ namespace NzbDrone.Core.MediaFiles var series = _seriesService.GetSeries(message.SeriesId); var episodeFiles = _mediaFileService.GetFilesBySeries(message.SeriesId); - _logger.Info("Renaming {0} files for {1}", episodeFiles.Count, series.Title); + _logger.Progress("Renaming {0} files for {1}", episodeFiles.Count, series.Title); RenameFiles(episodeFiles, series); - _logger.Debug("Episode Fies renamed for {0}", series.Title); + _logger.Complete("Episode Fies renamed for {0}", series.Title); } } } diff --git a/NzbDrone.Core/ProgressMessaging/ProgressMessageTarget.cs b/NzbDrone.Core/ProgressMessaging/ProgressMessageTarget.cs index ee99f7599..d11d33bd0 100644 --- a/NzbDrone.Core/ProgressMessaging/ProgressMessageTarget.cs +++ b/NzbDrone.Core/ProgressMessaging/ProgressMessageTarget.cs @@ -56,7 +56,12 @@ namespace NzbDrone.Core.ProgressMessaging return; } - var status = logEvent.Properties.ContainsKey("Status") ? (ProcessState)logEvent.Properties["Status"] : ProcessState.Running; + if (!logEvent.Properties.ContainsKey("Status")) + { + return; + } + + var status = (ProcessState)logEvent.Properties["Status"]; var message = new ProgressMessage(); message.Time = logEvent.TimeStamp; diff --git a/NzbDrone.Core/Tv/EpisodeService.cs b/NzbDrone.Core/Tv/EpisodeService.cs index 7747510d8..11a345c46 100644 --- a/NzbDrone.Core/Tv/EpisodeService.cs +++ b/NzbDrone.Core/Tv/EpisodeService.cs @@ -129,7 +129,7 @@ namespace NzbDrone.Core.Tv var episode = _episodeRepository.Get(episodeId); _episodeRepository.SetMonitoredFlat(episode, monitored); - logger.Info("Monitored flag for Episode:{0} was set to {1}", episodeId, monitored); + logger.Debug("Monitored flag for Episode:{0} was set to {1}", episodeId, monitored); } public void SetEpisodeMonitoredBySeason(int seriesId, int seasonNumber, bool monitored) diff --git a/NzbDrone.Core/Tv/RefreshEpisodeService.cs b/NzbDrone.Core/Tv/RefreshEpisodeService.cs index c62d8a5d2..6c2e1c4b0 100644 --- a/NzbDrone.Core/Tv/RefreshEpisodeService.cs +++ b/NzbDrone.Core/Tv/RefreshEpisodeService.cs @@ -30,7 +30,7 @@ namespace NzbDrone.Core.Tv public void RefreshEpisodeInfo(Series series, IEnumerable remoteEpisodes) { - _logger.Info("Starting series info refresh for: {0}", series); + _logger.Info("Starting episode info refresh for: {0}", series); var successCount = 0; var failCount = 0; diff --git a/NzbDrone.Core/Tv/RefreshSeriesService.cs b/NzbDrone.Core/Tv/RefreshSeriesService.cs index bbdb8e472..6e9f38dda 100644 --- a/NzbDrone.Core/Tv/RefreshSeriesService.cs +++ b/NzbDrone.Core/Tv/RefreshSeriesService.cs @@ -2,6 +2,7 @@ using System.IO; using System.Linq; using NLog; +using NzbDrone.Common.Instrumentation; using NzbDrone.Common.Messaging; using NzbDrone.Core.DataAugmentation.DailySeries; using NzbDrone.Core.MetadataSource; @@ -30,39 +31,9 @@ namespace NzbDrone.Core.Tv _logger = logger; } - - public void Execute(RefreshSeriesCommand message) - { - if (message.SeriesId.HasValue) - { - var series = _seriesService.GetSeries(message.SeriesId.Value); - RefreshSeriesInfo(series); - } - else - { - var allSeries = _seriesService.GetAllSeries().OrderBy(c => c.LastInfoSync).ToList(); - - foreach (var series in allSeries) - { - try - { - RefreshSeriesInfo(series); - } - catch (Exception e) - { - _logger.ErrorException("Couldn't refresh info for {0}".Inject(series), e); - } - } - } - } - - public void HandleAsync(SeriesAddedEvent message) - { - RefreshSeriesInfo(message.Series); - } - private void RefreshSeriesInfo(Series series) { + _logger.Progress("Starting Series Refresh for {0}", series.Title); var tuple = _seriesInfo.GetSeriesInfo(series.TvdbId); var seriesInfo = tuple.Item1; @@ -96,7 +67,38 @@ namespace NzbDrone.Core.Tv _seriesService.UpdateSeries(series); _refreshEpisodeService.RefreshEpisodeInfo(series, tuple.Item2); + _logger.Complete("Finished series refresh for {0}", series.Title); _messageAggregator.PublishEvent(new SeriesUpdatedEvent(series)); } + + public void Execute(RefreshSeriesCommand message) + { + if (message.SeriesId.HasValue) + { + var series = _seriesService.GetSeries(message.SeriesId.Value); + RefreshSeriesInfo(series); + } + else + { + var allSeries = _seriesService.GetAllSeries().OrderBy(c => c.LastInfoSync).ToList(); + + foreach (var series in allSeries) + { + try + { + RefreshSeriesInfo(series); + } + catch (Exception e) + { + _logger.ErrorException("Couldn't refresh info for {0}".Inject(series), e); + } + } + } + } + + public void HandleAsync(SeriesAddedEvent message) + { + RefreshSeriesInfo(message.Series); + } } } \ No newline at end of file diff --git a/UI/Episode/Search/Layout.js b/UI/Episode/Search/Layout.js index aa24febf5..61f101ac7 100644 --- a/UI/Episode/Search/Layout.js +++ b/UI/Episode/Search/Layout.js @@ -46,12 +46,11 @@ define( var message = seriesTitle + ' - ' + season + 'x' + FormatHelpers.pad(episode, 2); Actioneer.ExecuteCommand({ - command : 'episodeSearch', - properties : { + command : 'episodeSearch', + properties: { episodeId: this.model.get('id') }, - errorMessage: 'Search failed for: ' + message, - startMessage: 'Search started for: ' + message + errorMessage: 'Search failed for: ' + message }); App.vent.trigger(App.Commands.CloseModalCommand); diff --git a/UI/ProgressMessaging/ProgressMessageCollection.js b/UI/ProgressMessaging/ProgressMessageCollection.js index eb7317b4d..58a5da850 100644 --- a/UI/ProgressMessaging/ProgressMessageCollection.js +++ b/UI/ProgressMessaging/ProgressMessageCollection.js @@ -17,11 +17,13 @@ define( collection.signalRconnection.received(function (message) { var type = getMessengerType(message.status); + var hideAfter = type === 'info' ? 60 : 5; Messenger.show({ - id : message.commandId, - message: message.message, - type : type + id : message.commandId, + message : message.message, + type : type, + hideAfter: hideAfter }); }); diff --git a/UI/Shared/Actioneer.js b/UI/Shared/Actioneer.js index 516a0e7b7..847e8cec4 100644 --- a/UI/Shared/Actioneer.js +++ b/UI/Shared/Actioneer.js @@ -92,6 +92,10 @@ define( }, _getIconClass: function(element) { + if (!element) { + return ''; + } + return element.attr('class').match(/(?:^|\s)icon\-.+?(?:$|\s)/)[0]; }, @@ -143,14 +147,16 @@ define( options.button.removeClass('disable'); } - if (options.leaveIcon) { - options.element.removeClass('icon-spin'); - } + if (options.element) { + if (options.leaveIcon) { + options.element.removeClass('icon-spin'); + } - else { - options.element.addClass(options.iconClass); - options.element.removeClass('icon-nd-spinner'); - options.element.removeClass('icon-spin'); + else { + options.element.addClass(options.iconClass); + options.element.removeClass('icon-nd-spinner'); + options.element.removeClass('icon-spin'); + } } if (options.always) {