remove people refresh retry

This commit is contained in:
Luke Pulverenti 2016-08-04 00:38:58 -04:00
parent e08f5d5d61
commit 39245133f8
9 changed files with 16 additions and 133 deletions

View File

@ -11,11 +11,13 @@ namespace MediaBrowser.Controller.Entities
public int? MaxListOrder { get; set; }
public Guid AppearsInItemId { get; set; }
public string NameContains { get; set; }
public SourceType[] SourceTypes { get; set; }
public InternalPeopleQuery()
{
PersonTypes = new List<string>();
ExcludePersonTypes = new List<string>();
SourceTypes = new SourceType[] { };
}
}
}

View File

@ -474,12 +474,6 @@ namespace MediaBrowser.Controller.Library
/// <returns>List&lt;Person&gt;.</returns>
List<Person> GetPeopleItems(InternalPeopleQuery query);
/// <summary>
/// Gets all people names.
/// </summary>
/// <returns>List&lt;System.String&gt;.</returns>
List<PersonInfo> GetAllPeople();
/// <summary>
/// Updates the people.
/// </summary>

View File

@ -2605,13 +2605,6 @@ namespace MediaBrowser.Server.Implementations.Library
return ItemRepository.GetPeopleNames(query);
}
public List<PersonInfo> GetAllPeople()
{
return GetPeople(new InternalPeopleQuery())
.DistinctBy(i => i.Name, StringComparer.OrdinalIgnoreCase)
.ToList();
}
public Task UpdatePeople(BaseItem item, List<PersonInfo> people)
{
if (!item.SupportsPeople)

View File

@ -1,5 +1,4 @@
using System.Collections.Generic;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Logging;
using System;
@ -43,16 +42,12 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
var numComplete = 0;
var count = items.Count;
var validIds = new List<Guid>();
foreach (var name in items)
{
try
{
var itemByName = _libraryManager.GetGameGenre(name);
validIds.Add(itemByName.Id);
await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false);
}
catch (OperationCanceledException)
@ -73,28 +68,6 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
progress.Report(percent);
}
var allIds = _libraryManager.GetItemIds(new InternalItemsQuery
{
IncludeItemTypes = new[] { typeof(GameGenre).Name }
});
var invalidIds = allIds
.Except(validIds)
.ToList();
foreach (var id in invalidIds)
{
cancellationToken.ThrowIfCancellationRequested();
var item = _libraryManager.GetItemById(id);
await _libraryManager.DeleteItem(item, new DeleteOptions
{
DeleteFileLocation = false
}).ConfigureAwait(false);
}
progress.Report(100);
}
}

View File

@ -1,5 +1,4 @@
using System.Collections.Generic;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Logging;
@ -44,16 +43,12 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
var numComplete = 0;
var count = items.Count;
var validIds = new List<Guid>();
foreach (var name in items)
{
try
{
var itemByName = _libraryManager.GetGenre(name);
validIds.Add(itemByName.Id);
await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false);
}
catch (OperationCanceledException)
@ -74,28 +69,6 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
progress.Report(percent);
}
var allIds = _libraryManager.GetItemIds(new InternalItemsQuery
{
IncludeItemTypes = new[] { typeof(Genre).Name }
});
var invalidIds = allIds
.Except(validIds)
.ToList();
foreach (var id in invalidIds)
{
cancellationToken.ThrowIfCancellationRequested();
var item = _libraryManager.GetItemById(id);
await _libraryManager.DeleteItem(item, new DeleteOptions
{
DeleteFileLocation = false
}).ConfigureAwait(false);
}
progress.Report(100);
}
}

View File

@ -1,6 +1,4 @@
using System.Collections.Generic;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Logging;
using System;
@ -44,16 +42,12 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
var numComplete = 0;
var count = items.Count;
var validIds = new List<Guid>();
foreach (var name in items)
{
try
{
var itemByName = _libraryManager.GetMusicGenre(name);
validIds.Add(itemByName.Id);
await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false);
}
catch (OperationCanceledException)
@ -74,28 +68,6 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
progress.Report(percent);
}
var allIds = _libraryManager.GetItemIds(new InternalItemsQuery
{
IncludeItemTypes = new[] { typeof(MusicGenre).Name }
});
var invalidIds = allIds
.Except(validIds)
.ToList();
foreach (var id in invalidIds)
{
cancellationToken.ThrowIfCancellationRequested();
var item = _libraryManager.GetItemById(id);
await _libraryManager.DeleteItem(item, new DeleteOptions
{
DeleteFileLocation = false
}).ConfigureAwait(false);
}
progress.Report(100);
}
}

View File

@ -89,7 +89,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
var peopleOptions = _config.Configuration.PeopleMetadataOptions;
var people = _libraryManager.GetAllPeople();
var people = _libraryManager.GetPeople(new InternalPeopleQuery());
var dict = new Dictionary<string, bool>(StringComparer.OrdinalIgnoreCase);
@ -112,8 +112,9 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
}
var numComplete = 0;
var validIds = new List<Guid>();
_logger.Debug("Will refresh {0} people", dict.Count);
foreach (var person in dict)
{
cancellationToken.ThrowIfCancellationRequested();
@ -122,10 +123,9 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
{
var item = _libraryManager.GetPerson(person.Key);
validIds.Add(item.Id);
var hasMetdata = !string.IsNullOrWhiteSpace(item.Overview);
var performFullRefresh = !hasMetdata && (DateTime.UtcNow - item.DateLastRefreshed).TotalDays >= 30;
var performFullRefresh = !hasMetdata && (DateTime.UtcNow - item.DateLastRefreshed).TotalDays >= 90;
performFullRefresh = false;
var defaultMetadataRefreshMode = performFullRefresh
? MetadataRefreshMode.FullRefresh
@ -160,31 +160,6 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
progress.Report(100 * percent);
}
var allIds = _libraryManager.GetItemIds(new InternalItemsQuery
{
IncludeItemTypes = new[] { typeof(Person).Name }
});
var invalidIds = allIds
.Except(validIds)
.ToList();
foreach (var id in invalidIds)
{
cancellationToken.ThrowIfCancellationRequested();
var item = _libraryManager.GetItemById(id);
if (item != null)
{
await _libraryManager.DeleteItem(item, new DeleteOptions
{
DeleteFileLocation = false
}).ConfigureAwait(false);
}
}
progress.Report(100);
_logger.Info("People validation complete");

View File

@ -42,16 +42,12 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
var numComplete = 0;
var count = items.Count;
var validIds = new List<Guid>();
foreach (var name in items)
{
try
{
var itemByName = _libraryManager.GetStudio(name);
validIds.Add(itemByName.Id);
await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false);
}
catch (OperationCanceledException)

View File

@ -3776,6 +3776,11 @@ namespace MediaBrowser.Server.Implementations.Persistence
whereClauses.Add("Name like @NameContains");
cmd.Parameters.Add(cmd, "@NameContains", DbType.String).Value = "%" + query.NameContains + "%";
}
if (query.SourceTypes.Length == 1)
{
whereClauses.Add("(select sourcetype from typedbaseitems where guid=ItemId) = @SourceTypes");
cmd.Parameters.Add(cmd, "@SourceTypes", DbType.String).Value = query.SourceTypes[0].ToString();
}
return whereClauses;
}