Skip to content

Commit

Permalink
cache plex library data regardless of whether we have requests in the…
Browse files Browse the repository at this point in the history
… database or not
  • Loading branch information
Drewster727 committed Apr 15, 2016
1 parent e8e7367 commit 4c6c0ae
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions PlexRequests.Services/PlexAvailabilityChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
using PlexRequests.Core;
using PlexRequests.Core.SettingModels;
using PlexRequests.Helpers;
using PlexRequests.Helpers.Exceptions;
using PlexRequests.Services.Interfaces;
using PlexRequests.Store;
using PlexRequests.Services.Models;
Expand Down Expand Up @@ -67,14 +66,10 @@ public void CheckAndUpdateAll(long check)
var plexSettings = Plex.GetSettings();
var authSettings = Auth.GetSettings();
Log.Trace("Getting all the requests");
var requests = RequestService.GetAll();

var requestedModels = requests as RequestedModel[] ?? requests.Where(x => !x.Available).ToArray();
Log.Trace("Requests Count {0}", requestedModels.Length);

if (!ValidateSettings(plexSettings, authSettings) || !requestedModels.Any())

if (!ValidateSettings(plexSettings, authSettings))
{
Log.Info("Validation of the settings failed or there is no requests.");
Log.Info("Validation of the plex settings failed.");
return;
}

Expand All @@ -83,6 +78,16 @@ public void CheckAndUpdateAll(long check)
var shows = GetPlexTvShows().ToArray();
var albums = GetPlexAlbums().ToArray();

var requests = RequestService.GetAll();
var requestedModels = requests as RequestedModel[] ?? requests.Where(x => !x.Available).ToArray();
Log.Trace("Requests Count {0}", requestedModels.Length);

if (!requestedModels.Any())
{
Log.Info("There are no requests to check.");
return;
}

var modifiedModel = new List<RequestedModel>();
foreach (var r in requestedModels)
{
Expand Down

0 comments on commit 4c6c0ae

Please sign in to comment.