mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-30 11:38:32 -07:00
Added some code to shrink the DB. reworked the search to speed it up.
This commit is contained in:
parent
97b1901a64
commit
6f008f77a3
6 changed files with 156 additions and 156 deletions
|
@ -53,6 +53,11 @@ namespace PlexRequests.Core
|
||||||
{
|
{
|
||||||
CreateDefaultSettingsPage(urlBase);
|
CreateDefaultSettingsPage(urlBase);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Shrink DB
|
||||||
|
TableCreation.Vacuum(Db.DbConnection());
|
||||||
|
}
|
||||||
|
|
||||||
var version = CheckSchema();
|
var version = CheckSchema();
|
||||||
if (version > 0)
|
if (version > 0)
|
||||||
|
|
|
@ -61,12 +61,9 @@ namespace PlexRequests.Services.Jobs
|
||||||
|
|
||||||
public void Queued()
|
public void Queued()
|
||||||
{
|
{
|
||||||
Log.Trace("Getting the settings");
|
|
||||||
|
|
||||||
var settings = SonarrSettings.GetSettings();
|
var settings = SonarrSettings.GetSettings();
|
||||||
if (settings.Enabled)
|
if (settings.Enabled)
|
||||||
{
|
{
|
||||||
Log.Trace("Getting all tv series from Sonarr");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var series = SonarrApi.GetSeries(settings.ApiKey, settings.FullUri);
|
var series = SonarrApi.GetSeries(settings.ApiKey, settings.FullUri);
|
||||||
|
|
|
@ -75,6 +75,17 @@ namespace PlexRequests.Store
|
||||||
connection.Close();
|
connection.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void Vacuum(IDbConnection con)
|
||||||
|
{
|
||||||
|
using (con)
|
||||||
|
{
|
||||||
|
con.Open();
|
||||||
|
|
||||||
|
con.Query("VACUUM;");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static DbInfo GetSchemaVersion(this IDbConnection con)
|
public static DbInfo GetSchemaVersion(this IDbConnection con)
|
||||||
{
|
{
|
||||||
con.Open();
|
con.Open();
|
||||||
|
|
|
@ -314,8 +314,6 @@ namespace PlexRequests.UI.Modules
|
||||||
var viewTv = new List<SearchTvShowViewModel>();
|
var viewTv = new List<SearchTvShowViewModel>();
|
||||||
foreach (var t in apiTv)
|
foreach (var t in apiTv)
|
||||||
{
|
{
|
||||||
var tvInfoTask = Task.Run(() => TvApi.EpisodeLookup(t.show.id));
|
|
||||||
|
|
||||||
var banner = t.show.image?.medium;
|
var banner = t.show.image?.medium;
|
||||||
if (!string.IsNullOrEmpty(banner))
|
if (!string.IsNullOrEmpty(banner))
|
||||||
{
|
{
|
||||||
|
@ -351,7 +349,6 @@ namespace PlexRequests.UI.Modules
|
||||||
else if (t.show?.externals?.thetvdb != null)
|
else if (t.show?.externals?.thetvdb != null)
|
||||||
{
|
{
|
||||||
var tvdbid = (int)t.show.externals.thetvdb;
|
var tvdbid = (int)t.show.externals.thetvdb;
|
||||||
|
|
||||||
if (dbTv.ContainsKey(tvdbid))
|
if (dbTv.ContainsKey(tvdbid))
|
||||||
{
|
{
|
||||||
var dbt = dbTv[tvdbid];
|
var dbt = dbTv[tvdbid];
|
||||||
|
@ -361,20 +358,12 @@ namespace PlexRequests.UI.Modules
|
||||||
viewT.Approved = dbt.Approved;
|
viewT.Approved = dbt.Approved;
|
||||||
viewT.Available = dbt.Available;
|
viewT.Available = dbt.Available;
|
||||||
}
|
}
|
||||||
else if (sonarrCached.Contains(tvdbid) || sickRageCache.Contains(tvdbid)) // compare to the sonarr/sickrage db
|
if (sonarrCached.Contains(tvdbid) || sickRageCache.Contains(tvdbid)) // compare to the sonarr/sickrage db
|
||||||
{
|
{
|
||||||
viewT.Requested = true;
|
viewT.Requested = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var tvInfo = await tvInfoTask;
|
|
||||||
|
|
||||||
// Check if we have every episode in all seasons
|
|
||||||
var epModel = tvInfo.Select(tvIn => new Store.EpisodesModel { SeasonNumber = tvIn.season, EpisodeNumber = tvIn.number }).ToList();
|
|
||||||
var diff = viewT.Episodes.Except(epModel);
|
|
||||||
if (diff.Any())
|
|
||||||
{
|
|
||||||
viewT.TvFullyAvailable = true;
|
|
||||||
}
|
|
||||||
viewTv.Add(viewT);
|
viewTv.Add(viewT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -978,11 +967,11 @@ namespace PlexRequests.UI.Modules
|
||||||
|
|
||||||
var model = new List<EpisodeListViewModel>();
|
var model = new List<EpisodeListViewModel>();
|
||||||
|
|
||||||
var enumerable = allResults as RequestedModel[] ?? allResults.ToArray();
|
var requests = allResults as RequestedModel[] ?? allResults.ToArray();
|
||||||
|
|
||||||
var dbDbShow = enumerable.FirstOrDefault(x => x.Type == RequestType.TvShow && x.TvDbId == seriesId.ToString());
|
var existingRequest = requests.FirstOrDefault(x => x.Type == RequestType.TvShow && x.TvDbId == seriesId.ToString());
|
||||||
var show = await Task.Run(() => TvApi.ShowLookupByTheTvDbId(seriesId));
|
var show = await Task.Run(() => TvApi.ShowLookupByTheTvDbId(seriesId));
|
||||||
var seasons = await Task.Run(() => TvApi.EpisodeLookup(show.id));
|
var tvMaxeEpisodes = await Task.Run(() => TvApi.EpisodeLookup(show.id));
|
||||||
|
|
||||||
var sonarrEpisodes = new List<SonarrEpisodes>();
|
var sonarrEpisodes = new List<SonarrEpisodes>();
|
||||||
if (sonarrEnabled)
|
if (sonarrEnabled)
|
||||||
|
@ -994,9 +983,9 @@ namespace PlexRequests.UI.Modules
|
||||||
|
|
||||||
var plexCacheTask = await Checker.GetEpisodes(seriesId);
|
var plexCacheTask = await Checker.GetEpisodes(seriesId);
|
||||||
var plexCache = plexCacheTask.ToList();
|
var plexCache = plexCacheTask.ToList();
|
||||||
foreach (var ep in seasons)
|
foreach (var ep in tvMaxeEpisodes)
|
||||||
{
|
{
|
||||||
var requested = dbDbShow?.Episodes
|
var requested = existingRequest?.Episodes
|
||||||
.Any(episodesModel =>
|
.Any(episodesModel =>
|
||||||
ep.number == episodesModel.EpisodeNumber && ep.season == episodesModel.SeasonNumber) ?? false;
|
ep.number == episodesModel.EpisodeNumber && ep.season == episodesModel.SeasonNumber) ?? false;
|
||||||
|
|
||||||
|
|
|
@ -149,10 +149,7 @@ namespace PlexRequests.UI
|
||||||
var settingsService = new SettingsServiceV2<LogSettings>(new SettingsJsonRepository(new DbConfiguration(new SqliteFactory()), new MemoryCacheProvider()));
|
var settingsService = new SettingsServiceV2<LogSettings>(new SettingsJsonRepository(new DbConfiguration(new SqliteFactory()), new MemoryCacheProvider()));
|
||||||
var logSettings = settingsService.GetSettings();
|
var logSettings = settingsService.GetSettings();
|
||||||
|
|
||||||
if (logSettings != null)
|
LoggingHelper.ReconfigureLogLevel(logSettings != null ? LogLevel.FromOrdinal(logSettings.Level) : LogLevel.FromOrdinal(4));
|
||||||
{
|
|
||||||
LoggingHelper.ReconfigureLogLevel(LogLevel.FromOrdinal(logSettings.Level));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void PrintToConsole(string message, ConsoleColor colour = ConsoleColor.Gray)
|
private static void PrintToConsole(string message, ConsoleColor colour = ConsoleColor.Gray)
|
||||||
|
|
|
@ -185,6 +185,7 @@
|
||||||
{{/if_eq}}
|
{{/if_eq}}
|
||||||
{{#if_eq type "tv"}}
|
{{#if_eq type "tv"}}
|
||||||
{{#if_eq tvFullyAvailable true}}
|
{{#if_eq tvFullyAvailable true}}
|
||||||
|
@*//TODO Not used yet*@
|
||||||
<button style="text-align: right" class="btn btn-success-outline disabled" disabled><i class="fa fa-check"></i> @UI.Search_Available</button>
|
<button style="text-align: right" class="btn btn-success-outline disabled" disabled><i class="fa fa-check"></i> @UI.Search_Available</button>
|
||||||
{{else}}
|
{{else}}
|
||||||
<div class="dropdown">
|
<div class="dropdown">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue