rework storage of PresentationUniqueKey

This commit is contained in:
Luke Pulverenti 2016-08-12 15:11:45 -04:00
parent 7551317075
commit d9ee4f81fd
13 changed files with 67 additions and 73 deletions

View File

@ -169,13 +169,9 @@ namespace MediaBrowser.Controller.Entities.Audio
list.Add("Artist-" + (item.Name ?? string.Empty).RemoveDiacritics());
return list;
}
public override string PresentationUniqueKey
public override string CreatePresentationUniqueKey()
{
get
{
return "Artist-" + (Name ?? string.Empty).RemoveDiacritics();
}
return "Artist-" + (Name ?? string.Empty).RemoveDiacritics();
}
protected override bool GetBlockUnratedValue(UserPolicy config)
{

View File

@ -18,13 +18,9 @@ namespace MediaBrowser.Controller.Entities.Audio
list.Insert(0, GetType().Name + "-" + (Name ?? string.Empty).RemoveDiacritics());
return list;
}
public override string PresentationUniqueKey
public override string CreatePresentationUniqueKey()
{
get
{
return GetUserDataKeys()[0];
}
return GetUserDataKeys()[0];
}
[IgnoreDataMember]

View File

@ -1194,10 +1194,17 @@ namespace MediaBrowser.Controller.Entities
get { return null; }
}
[IgnoreDataMember]
public virtual string PresentationUniqueKey
public virtual string CreatePresentationUniqueKey()
{
get { return Id.ToString("N"); }
return Id.ToString("N");
}
[IgnoreDataMember]
public string PresentationUniqueKey { get; set; }
public string GetPresentationUniqueKey()
{
return PresentationUniqueKey ?? CreatePresentationUniqueKey();
}
public virtual bool RequiresRefresh()

View File

@ -16,12 +16,9 @@ namespace MediaBrowser.Controller.Entities
return list;
}
public override string PresentationUniqueKey
public override string CreatePresentationUniqueKey()
{
get
{
return GetUserDataKeys()[0];
}
return GetUserDataKeys()[0];
}
/// <summary>

View File

@ -19,13 +19,9 @@ namespace MediaBrowser.Controller.Entities
list.Insert(0, GetType().Name + "-" + (Name ?? string.Empty).RemoveDiacritics());
return list;
}
public override string PresentationUniqueKey
public override string CreatePresentationUniqueKey()
{
get
{
return GetUserDataKeys()[0];
}
return GetUserDataKeys()[0];
}
/// <summary>

View File

@ -26,13 +26,9 @@ namespace MediaBrowser.Controller.Entities
list.Insert(0, GetType().Name + "-" + (Name ?? string.Empty).RemoveDiacritics());
return list;
}
public override string PresentationUniqueKey
public override string CreatePresentationUniqueKey()
{
get
{
return GetUserDataKeys()[0];
}
return GetUserDataKeys()[0];
}
public PersonLookupInfo GetLookupInfo()

View File

@ -18,13 +18,9 @@ namespace MediaBrowser.Controller.Entities
list.Insert(0, GetType().Name + "-" + (Name ?? string.Empty).RemoveDiacritics());
return list;
}
public override string PresentationUniqueKey
public override string CreatePresentationUniqueKey()
{
get
{
return GetUserDataKeys()[0];
}
return GetUserDataKeys()[0];
}
/// <summary>

View File

@ -114,22 +114,18 @@ namespace MediaBrowser.Controller.Entities.TV
}
}
[IgnoreDataMember]
public override string PresentationUniqueKey
public override string CreatePresentationUniqueKey()
{
get
if (IndexNumber.HasValue)
{
if (IndexNumber.HasValue)
var series = Series;
if (series != null)
{
var series = Series;
if (series != null)
{
return series.PresentationUniqueKey + "-" + (IndexNumber ?? 0).ToString("000");
}
return series.PresentationUniqueKey + "-" + (IndexNumber ?? 0).ToString("000");
}
return base.PresentationUniqueKey;
}
return base.CreatePresentationUniqueKey();
}
/// <summary>

View File

@ -96,19 +96,30 @@ namespace MediaBrowser.Controller.Entities.TV
}
}
[IgnoreDataMember]
public override string PresentationUniqueKey
public override string CreatePresentationUniqueKey()
{
get
{
var userdatakeys = GetUserDataKeys();
var userdatakeys = GetUserDataKeys();
if (userdatakeys.Count > 1)
{
return userdatakeys[0];
}
return base.PresentationUniqueKey;
if (userdatakeys.Count > 1)
{
return AddLibrariesToPresentationUniqueKey(userdatakeys[0]);
}
return base.CreatePresentationUniqueKey();
}
private string AddLibrariesToPresentationUniqueKey(string key)
{
return key;
//var folders = LibraryManager.GetCollectionFolders(this)
// .Select(i => i.Id.ToString("N"))
// .ToArray();
//if (folders.Length == 0)
//{
// return key;
//}
//return key + "-" + string.Join("-", folders);
}
private static string GetUniqueSeriesKey(BaseItem series)
@ -117,7 +128,7 @@ namespace MediaBrowser.Controller.Entities.TV
{
return series.Id.ToString("N");
}
return series.PresentationUniqueKey;
return series.GetPresentationUniqueKey();
}
public override int GetChildCount(User user)

View File

@ -1198,7 +1198,7 @@ namespace MediaBrowser.Controller.Entities
{
var user = query.User;
items = items.DistinctBy(i => i.PresentationUniqueKey, StringComparer.OrdinalIgnoreCase);
items = items.DistinctBy(i => i.GetPresentationUniqueKey(), StringComparer.OrdinalIgnoreCase);
if (query.SortBy.Length > 0)
{

View File

@ -44,18 +44,14 @@ namespace MediaBrowser.Controller.Entities
}
}
[IgnoreDataMember]
public override string PresentationUniqueKey
public override string CreatePresentationUniqueKey()
{
get
if (!string.IsNullOrWhiteSpace(PrimaryVersionId))
{
if (!string.IsNullOrWhiteSpace(PrimaryVersionId))
{
return PrimaryVersionId;
}
return base.PresentationUniqueKey;
return PrimaryVersionId;
}
return base.CreatePresentationUniqueKey();
}
[IgnoreDataMember]

View File

@ -412,7 +412,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
"SeasonName",
"SeasonId",
"SeriesId",
"SeriesSortName"
"SeriesSortName",
"PresentationUniqueKey"
};
private readonly string[] _mediaStreamSaveColumns =
@ -918,7 +919,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
_saveItemCommand.GetParameter(index++).Value = GetCleanValue(item.Name);
}
_saveItemCommand.GetParameter(index++).Value = item.PresentationUniqueKey;
_saveItemCommand.GetParameter(index++).Value = item.GetPresentationUniqueKey();
_saveItemCommand.GetParameter(index++).Value = item.SlugName;
_saveItemCommand.GetParameter(index++).Value = item.OriginalTitle;
@ -1454,6 +1455,12 @@ namespace MediaBrowser.Server.Implementations.Persistence
}
index++;
if (!reader.IsDBNull(index))
{
item.PresentationUniqueKey = reader.GetString(index);
}
index++;
return item;
}

View File

@ -152,7 +152,7 @@ namespace MediaBrowser.Server.Implementations.TV
{
return series.Id.ToString("N");
}
return series.PresentationUniqueKey;
return series.GetPresentationUniqueKey();
}
/// <summary>