mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-16 02:02:55 -07:00
Made some improvements to the Sonarr Sync job #2127
This commit is contained in:
parent
20a9720fdd
commit
3aad8bbe6b
1 changed files with 8 additions and 5 deletions
|
@ -1,6 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
@ -43,14 +45,15 @@ namespace Ombi.Schedule.Jobs.Sonarr
|
|||
var series = await _api.GetSeries(settings.ApiKey, settings.FullUri);
|
||||
if (series != null)
|
||||
{
|
||||
var sonarrSeries = series as IList<SonarrSeries> ?? series.ToList();
|
||||
var sonarrSeries = series as ImmutableHashSet<SonarrSeries> ?? series.ToImmutableHashSet();
|
||||
var ids = sonarrSeries.Select(x => x.tvdbId);
|
||||
|
||||
await _ctx.Database.ExecuteSqlCommandAsync("DELETE FROM SonarrCache");
|
||||
var entites = ids.Select(id => new SonarrCache { TvDbId = id }).ToList();
|
||||
var entites = ids.Select(id => new SonarrCache { TvDbId = id }).ToImmutableHashSet();
|
||||
|
||||
await _ctx.SonarrCache.AddRangeAsync(entites);
|
||||
|
||||
entites.Clear();
|
||||
|
||||
await _ctx.Database.ExecuteSqlCommandAsync("DELETE FROM SonarrEpisodeCache");
|
||||
foreach (var s in sonarrSeries)
|
||||
{
|
||||
|
@ -67,10 +70,10 @@ namespace Ombi.Schedule.Jobs.Sonarr
|
|||
TvDbId = s.tvdbId,
|
||||
HasFile = episode.hasFile
|
||||
}));
|
||||
_log.LogDebug("Commiting the transaction");
|
||||
await _ctx.SaveChangesAsync();
|
||||
}
|
||||
|
||||
_log.LogDebug("Commiting the transaction");
|
||||
await _ctx.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue