mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-14 02:26:55 -07:00
Reduce the memory consumption #1720
This commit is contained in:
parent
7ce1c0cb99
commit
ee13720a8b
3 changed files with 14 additions and 15 deletions
|
@ -63,7 +63,7 @@ namespace Ombi.Schedule.Jobs.Emby
|
|||
|
||||
private async Task ProcessMovies()
|
||||
{
|
||||
var movies = await _movieRepo.GetAll().Where(x => !x.Available).ToListAsync();
|
||||
var movies = _movieRepo.GetAll().Where(x => !x.Available);
|
||||
|
||||
foreach (var movie in movies)
|
||||
{
|
||||
|
@ -98,18 +98,18 @@ namespace Ombi.Schedule.Jobs.Emby
|
|||
/// <returns></returns>
|
||||
private async Task ProcessTv()
|
||||
{
|
||||
var tv = await _tvRepo.GetChild().Where(x => !x.Available).ToListAsync();
|
||||
var embyEpisodes = await _repo.GetAllEpisodes().Include(x => x.Series).ToListAsync();
|
||||
var tv = _tvRepo.GetChild().Where(x => !x.Available);
|
||||
var embyEpisodes = _repo.GetAllEpisodes().Include(x => x.Series);
|
||||
|
||||
foreach (var child in tv)
|
||||
{
|
||||
var tvDbId = child.ParentRequest.TvDbId;
|
||||
var seriesEpisodes = embyEpisodes.Where(x => x.Series.ProviderId == tvDbId.ToString()).ToList();
|
||||
var seriesEpisodes = embyEpisodes.Where(x => x.Series.ProviderId == tvDbId.ToString());
|
||||
foreach (var season in child.SeasonRequests)
|
||||
{
|
||||
foreach (var episode in season.Episodes)
|
||||
{
|
||||
var foundEp = seriesEpisodes.FirstOrDefault(
|
||||
var foundEp = await seriesEpisodes.FirstOrDefaultAsync(
|
||||
x => x.EpisodeNumber == episode.EpisodeNumber &&
|
||||
x.SeasonNumber == episode.Season.SeasonNumber);
|
||||
|
||||
|
|
|
@ -39,8 +39,8 @@ namespace Ombi.Schedule.Jobs.Plex
|
|||
|
||||
private async Task ProcessTv()
|
||||
{
|
||||
var tv = await _tvRepo.GetChild().Where(x => !x.Available).ToListAsync();
|
||||
var plexEpisodes = await _repo.GetAllEpisodes().Include(x => x.Series).ToListAsync();
|
||||
var tv = _tvRepo.GetChild().Where(x => !x.Available);
|
||||
var plexEpisodes = _repo.GetAllEpisodes().Include(x => x.Series);
|
||||
|
||||
foreach (var child in tv)
|
||||
{
|
||||
|
@ -60,20 +60,20 @@ namespace Ombi.Schedule.Jobs.Plex
|
|||
|
||||
var tvDbId = child.ParentRequest.TvDbId;
|
||||
var imdbId = child.ParentRequest.ImdbId;
|
||||
List<PlexEpisode> seriesEpisodes = null;
|
||||
IQueryable<PlexEpisode> seriesEpisodes = null;
|
||||
if (useImdb)
|
||||
{
|
||||
seriesEpisodes = plexEpisodes.Where(x => x.Series.ImdbId == imdbId.ToString()).ToList();
|
||||
seriesEpisodes = plexEpisodes.Where(x => x.Series.ImdbId == imdbId.ToString());
|
||||
}
|
||||
if (useTvDb)
|
||||
{
|
||||
seriesEpisodes = plexEpisodes.Where(x => x.Series.TvDbId == tvDbId.ToString()).ToList();
|
||||
seriesEpisodes = plexEpisodes.Where(x => x.Series.TvDbId == tvDbId.ToString());
|
||||
}
|
||||
foreach (var season in child.SeasonRequests)
|
||||
{
|
||||
foreach (var episode in season.Episodes)
|
||||
{
|
||||
var foundEp = seriesEpisodes.FirstOrDefault(
|
||||
var foundEp = await seriesEpisodes.FirstOrDefaultAsync(
|
||||
x => x.EpisodeNumber == episode.EpisodeNumber &&
|
||||
x.SeasonNumber == episode.Season.SeasonNumber);
|
||||
|
||||
|
@ -107,7 +107,7 @@ namespace Ombi.Schedule.Jobs.Plex
|
|||
private async Task ProcessMovies()
|
||||
{
|
||||
// Get all non available
|
||||
var movies = await _movieRepo.GetAll().Where(x => !x.Available).ToListAsync();
|
||||
var movies = _movieRepo.GetAll().Where(x => !x.Available);
|
||||
|
||||
foreach (var movie in movies)
|
||||
{
|
||||
|
|
|
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Hangfire;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Ombi.Api.Plex;
|
||||
using Ombi.Api.Plex.Models;
|
||||
|
@ -99,7 +98,7 @@ namespace Ombi.Schedule.Jobs.Plex
|
|||
var currentPosition = 0;
|
||||
var resultCount = settings.EpisodeBatchSize == 0 ? 50 : settings.EpisodeBatchSize;
|
||||
var episodes = await _api.GetAllEpisodes(settings.PlexAuthToken, settings.FullUri, section.key, currentPosition, resultCount);
|
||||
var currentData = await _repo.GetAllEpisodes().ToListAsync();
|
||||
var currentData = _repo.GetAllEpisodes();
|
||||
_log.LogInformation(LoggingEvents.PlexEpisodeCacher, $"Total Epsiodes found for {episodes.MediaContainer.librarySectionTitle} = {episodes.MediaContainer.totalSize}");
|
||||
|
||||
await ProcessEpsiodes(episodes, currentData);
|
||||
|
@ -119,7 +118,7 @@ namespace Ombi.Schedule.Jobs.Plex
|
|||
await _repo.SaveChangesAsync();
|
||||
}
|
||||
|
||||
private async Task ProcessEpsiodes(PlexContainer episodes, IEnumerable<PlexEpisode> currentEpisodes)
|
||||
private async Task ProcessEpsiodes(PlexContainer episodes, IQueryable<PlexEpisode> currentEpisodes)
|
||||
{
|
||||
var ep = new HashSet<PlexEpisode>();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue