aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2016-08-04 00:38:58 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2016-08-04 00:38:58 -0400
commit39245133f805e75164556fad9135e4f56925c33f (patch)
tree1b7e59eb7e3447cab6186d6c2ec62aed46c3508f
parente08f5d5d613b0f21676cfbb366940c72741a87df (diff)
remove people refresh retry
-rw-r--r--MediaBrowser.Controller/Entities/InternalPeopleQuery.cs2
-rw-r--r--MediaBrowser.Controller/Library/ILibraryManager.cs6
-rw-r--r--MediaBrowser.Server.Implementations/Library/LibraryManager.cs7
-rw-r--r--MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs29
-rw-r--r--MediaBrowser.Server.Implementations/Library/Validators/GenresValidator.cs29
-rw-r--r--MediaBrowser.Server.Implementations/Library/Validators/MusicGenresValidator.cs30
-rw-r--r--MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs37
-rw-r--r--MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs4
-rw-r--r--MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs5
9 files changed, 16 insertions, 133 deletions
diff --git a/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs b/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs
index 05d23d986..2ba6842ca 100644
--- a/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs
+++ b/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs
@@ -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[] { };
}
}
}
diff --git a/MediaBrowser.Controller/Library/ILibraryManager.cs b/MediaBrowser.Controller/Library/ILibraryManager.cs
index ad38b9ea5..70bd3f081 100644
--- a/MediaBrowser.Controller/Library/ILibraryManager.cs
+++ b/MediaBrowser.Controller/Library/ILibraryManager.cs
@@ -475,12 +475,6 @@ namespace MediaBrowser.Controller.Library
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>
/// <param name="item">The item.</param>
diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs
index 712ea4ef3..015fc3778 100644
--- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs
+++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs
@@ -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)
diff --git a/MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs
index 826154fac..a149da651 100644
--- a/MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs
+++ b/MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs
@@ -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);
}
}
diff --git a/MediaBrowser.Server.Implementations/Library/Validators/GenresValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/GenresValidator.cs
index 11d4c9f16..fac5cfc35 100644
--- a/MediaBrowser.Server.Implementations/Library/Validators/GenresValidator.cs
+++ b/MediaBrowser.Server.Implementations/Library/Validators/GenresValidator.cs
@@ -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);
}
}
diff --git a/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresValidator.cs
index 0c8c56f5a..81433e5b3 100644
--- a/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresValidator.cs
+++ b/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresValidator.cs
@@ -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);
}
}
diff --git a/MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs
index 5c43f2e13..843080950 100644
--- a/MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs
+++ b/MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs
@@ -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");
diff --git a/MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs
index e697dbd90..259878566 100644
--- a/MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs
+++ b/MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs
@@ -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)
diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs
index 63dd29e0d..2ef878a20 100644
--- a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs
+++ b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs
@@ -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;
}