Fixed ##1492 and finished the episode searcher for #1464

pull/1510/head
Jamie.Rees 8 years ago
parent d7f0f61ece
commit 9ed6fd09a4

@ -5,6 +5,7 @@ namespace Ombi.Api.Plex.Models
public class Mediacontainer
{
public int size { get; set; }
public int totalSize { get; set; }
public bool allowSync { get; set; }
public string identifier { get; set; }
public string mediaTagPrefix { get; set; }

@ -90,17 +90,17 @@ namespace Ombi.DependencyInjection
services.AddEntityFrameworkSqlite().AddDbContext<OmbiContext>();
services.AddScoped<IOmbiContext, OmbiContext>();
services.AddTransient<ISettingsRepository, SettingsJsonRepository>();
services.AddTransient<ISettingsResolver, SettingsResolver>();
services.AddTransient<IPlexContentRepository, PlexContentRepository>();
services.AddTransient<INotificationTemplatesRepository, NotificationTemplatesRepository>();
services.AddScoped<ISettingsRepository, SettingsJsonRepository>();
services.AddScoped<ISettingsResolver, SettingsResolver>();
services.AddScoped<IPlexContentRepository, PlexContentRepository>();
services.AddScoped<INotificationTemplatesRepository, NotificationTemplatesRepository>();
services.AddTransient<ITvRequestRepository, TvRequestRepository>();
services.AddTransient<IMovieRequestRepository, MovieRequestRepository>();
services.AddTransient<IAuditRepository, AuditRepository>();
services.AddTransient<IApplicationConfigRepository, ApplicationConfigRepository>();
services.AddTransient<ITokenRepository, TokenRepository>();
services.AddTransient(typeof(ISettingsService<>), typeof(SettingsService<>));
services.AddScoped<ITvRequestRepository, TvRequestRepository>();
services.AddScoped<IMovieRequestRepository, MovieRequestRepository>();
services.AddScoped<IAuditRepository, AuditRepository>();
services.AddScoped<IApplicationConfigRepository, ApplicationConfigRepository>();
services.AddScoped<ITokenRepository, TokenRepository>();
services.AddScoped(typeof(ISettingsService<>), typeof(SettingsService<>));
}
public static void RegisterServices(this IServiceCollection services)
{

@ -83,10 +83,10 @@ namespace Ombi.Schedule.Jobs.Plex
continue;
}
}
// Get the episodes
await GetEpisodes(settings, section);
}
// Get the episodes
await GetEpisodes(settings, section);
}
}
@ -99,17 +99,17 @@ namespace Ombi.Schedule.Jobs.Plex
var ResultCount = 50;
var episodes = await _api.GetAllEpisodes(settings.PlexAuthToken, settings.FullUri, section.key, currentPosition, ResultCount);
_log.LogInformation(LoggingEvents.PlexEpisodeCacher, $"Total Epsiodes found for {episodes.MediaContainer.librarySectionTitle} = {episodes.MediaContainer.size}");
_log.LogInformation(LoggingEvents.PlexEpisodeCacher, $"Total Epsiodes found for {episodes.MediaContainer.librarySectionTitle} = {episodes.MediaContainer.totalSize}");
await ProcessEpsiodes(episodes);
currentPosition += ResultCount;
while (currentPosition < episodes.MediaContainer.size)
while (currentPosition < episodes.MediaContainer.totalSize)
{
var ep = await _api.GetAllEpisodes(settings.PlexAuthToken, settings.FullUri, section.key, currentPosition,
ResultCount);
await ProcessEpsiodes(ep);
_log.LogInformation(LoggingEvents.PlexEpisodeCacher, $"Processed {ResultCount} more episodes. Total Remaining {currentPosition - episodes.MediaContainer.size}");
_log.LogInformation(LoggingEvents.PlexEpisodeCacher, $"Processed {ResultCount} more episodes. Total Remaining {currentPosition - episodes.MediaContainer.totalSize}");
currentPosition += ResultCount;
}
@ -128,9 +128,9 @@ namespace Ombi.Schedule.Jobs.Plex
{
EpisodeNumber = episode.index,
SeasonNumber = episode.parentIndex,
GrandparentKey = episode.grandparentKey,
ParentKey = episode.parentKey,
Key = episode.key,
GrandparentKey = episode.grandparentRatingKey,
ParentKey = episode.parentRatingKey,
Key = episode.ratingKey,
Title = episode.title
});
}

@ -46,7 +46,11 @@ namespace Ombi.Settings.Settings
return new T();
}
result.Content = DecryptSettings(result);
return string.IsNullOrEmpty(result.Content) ? null : JsonConvert.DeserializeObject<T>(result.Content, SerializerSettings.Settings);
var obj = string.IsNullOrEmpty(result.Content) ? null : JsonConvert.DeserializeObject<T>(result.Content, SerializerSettings.Settings);
var model = obj;
return model;
}
public bool SaveSettings(T model)
@ -67,10 +71,10 @@ namespace Ombi.Settings.Settings
var modified = model;
modified.Id = entity.Id;
entity.Content = JsonConvert.SerializeObject(modified, SerializerSettings.Settings);
var globalSettings = new GlobalSettings { SettingsName = EntityName, Content = JsonConvert.SerializeObject(modified, SerializerSettings.Settings), Id = entity.Id };
globalSettings.Content = EncryptSettings(globalSettings);
Repo.Update(globalSettings);
entity.Content = EncryptSettings(entity);
Repo.Update(entity);
return true;
}
@ -85,7 +89,7 @@ namespace Ombi.Settings.Settings
var settings = new GlobalSettings { SettingsName = EntityName, Content = JsonConvert.SerializeObject(newEntity, SerializerSettings.Settings) };
settings.Content = EncryptSettings(settings);
var insertResult = await Repo.InsertAsync(settings).ConfigureAwait(false);
var insertResult = await Repo.InsertAsync(settings);
return insertResult != null;
}
@ -93,9 +97,10 @@ namespace Ombi.Settings.Settings
var modified = model;
modified.Id = entity.Id;
var globalSettings = new GlobalSettings { SettingsName = EntityName, Content = JsonConvert.SerializeObject(modified, SerializerSettings.Settings), Id = entity.Id };
globalSettings.Content = EncryptSettings(globalSettings);
await Repo.UpdateAsync(globalSettings).ConfigureAwait(false);
entity.Content = JsonConvert.SerializeObject(modified, SerializerSettings.Settings);
entity.Content = EncryptSettings(entity);
await Repo.UpdateAsync(entity);
return true;
}

@ -37,33 +37,27 @@ namespace Ombi.Store.Repository
public IEnumerable<GlobalSettings> GetAll()
{
var page = Db.Settings.ToList();
var page = Db.Settings.AsNoTracking().ToList();
return page;
}
public async Task<IEnumerable<GlobalSettings>> GetAllAsync()
{
var page = await Db.Settings.ToListAsync();
var page = await Db.Settings.AsNoTracking().ToListAsync();
return page;
}
public GlobalSettings Get(string pageName)
{
var entity = Db.Settings.FirstOrDefault(x => x.SettingsName == pageName);
if (entity == null)
{
throw new ArgumentNullException($"The setting {pageName} does not exist");
}
Db.Entry(entity).Reload();
var entity = Db.Settings.AsNoTracking().FirstOrDefault(x => x.SettingsName == pageName);
return entity;
}
public async Task<GlobalSettings> GetAsync(string settingsName)
{
var obj = await Db.Settings.FirstOrDefaultAsync(x => x.SettingsName == settingsName);
if (obj != null) Db.Entry(obj).Reload();
var obj = await Db.Settings.AsNoTracking().FirstOrDefaultAsync(x => x.SettingsName == settingsName);
return obj;
}
@ -75,6 +69,7 @@ namespace Ombi.Store.Repository
public async Task UpdateAsync(GlobalSettings entity)
{
Db.Update(entity);
await Db.SaveChangesAsync();
}

Loading…
Cancel
Save