mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-08 10:44:23 -04:00
fix duplicates in suggestions
This commit is contained in:
parent
02b0734029
commit
db1130166f
@ -156,7 +156,9 @@ namespace MediaBrowser.Api.Movies
|
|||||||
typeof(LiveTvProgram).Name
|
typeof(LiveTvProgram).Name
|
||||||
},
|
},
|
||||||
IsMovie = true,
|
IsMovie = true,
|
||||||
SimilarTo = item
|
SimilarTo = item,
|
||||||
|
EnableGroupByMetadataKey = true
|
||||||
|
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
var dtoOptions = GetDtoOptions(request);
|
var dtoOptions = GetDtoOptions(request);
|
||||||
@ -205,7 +207,8 @@ namespace MediaBrowser.Api.Movies
|
|||||||
SortOrder = SortOrder.Descending,
|
SortOrder = SortOrder.Descending,
|
||||||
Limit = 10,
|
Limit = 10,
|
||||||
IsFavoriteOrLiked = true,
|
IsFavoriteOrLiked = true,
|
||||||
ExcludeItemIds = recentlyPlayedMovies.Select(i => i.Id.ToString("N")).ToArray()
|
ExcludeItemIds = recentlyPlayedMovies.Select(i => i.Id.ToString("N")).ToArray(),
|
||||||
|
EnableGroupByMetadataKey = true
|
||||||
|
|
||||||
}, parentIds).ToList();
|
}, parentIds).ToList();
|
||||||
|
|
||||||
@ -283,7 +286,8 @@ namespace MediaBrowser.Api.Movies
|
|||||||
typeof(Trailer).Name,
|
typeof(Trailer).Name,
|
||||||
typeof(LiveTvProgram).Name
|
typeof(LiveTvProgram).Name
|
||||||
},
|
},
|
||||||
IsMovie = true
|
IsMovie = true,
|
||||||
|
EnableGroupByMetadataKey = true
|
||||||
|
|
||||||
}).DistinctBy(i => i.GetProviderId(MetadataProviders.Imdb) ?? Guid.NewGuid().ToString("N"))
|
}).DistinctBy(i => i.GetProviderId(MetadataProviders.Imdb) ?? Guid.NewGuid().ToString("N"))
|
||||||
.Take(itemLimit)
|
.Take(itemLimit)
|
||||||
@ -317,7 +321,8 @@ namespace MediaBrowser.Api.Movies
|
|||||||
typeof(Trailer).Name,
|
typeof(Trailer).Name,
|
||||||
typeof(LiveTvProgram).Name
|
typeof(LiveTvProgram).Name
|
||||||
},
|
},
|
||||||
IsMovie = true
|
IsMovie = true,
|
||||||
|
EnableGroupByMetadataKey = true
|
||||||
|
|
||||||
}).DistinctBy(i => i.GetProviderId(MetadataProviders.Imdb) ?? Guid.NewGuid().ToString("N"))
|
}).DistinctBy(i => i.GetProviderId(MetadataProviders.Imdb) ?? Guid.NewGuid().ToString("N"))
|
||||||
.Take(itemLimit)
|
.Take(itemLimit)
|
||||||
@ -350,7 +355,8 @@ namespace MediaBrowser.Api.Movies
|
|||||||
typeof(LiveTvProgram).Name
|
typeof(LiveTvProgram).Name
|
||||||
},
|
},
|
||||||
IsMovie = true,
|
IsMovie = true,
|
||||||
SimilarTo = item
|
SimilarTo = item,
|
||||||
|
EnableGroupByMetadataKey = true
|
||||||
|
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
public bool EnableTotalRecordCount { get; set; }
|
public bool EnableTotalRecordCount { get; set; }
|
||||||
public bool ForceDirect { get; set; }
|
public bool ForceDirect { get; set; }
|
||||||
public Dictionary<string, string> ExcludeProviderIds { get; set; }
|
public Dictionary<string, string> ExcludeProviderIds { get; set; }
|
||||||
public string GroupByAncestorOfType { get; set; }
|
public bool EnableGroupByMetadataKey { get; set; }
|
||||||
|
|
||||||
public InternalItemsQuery()
|
public InternalItemsQuery()
|
||||||
{
|
{
|
||||||
|
@ -1622,7 +1622,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (query.SimilarTo != null)
|
if (query.SimilarTo != null && query.User != null)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1757,11 +1757,6 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||||||
{
|
{
|
||||||
var groups = new List<string>();
|
var groups = new List<string>();
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(query.GroupByAncestorOfType))
|
|
||||||
{
|
|
||||||
groups.Add("(Select PresentationUniqueKey from TypedBaseItems B where B.Type = 'MediaBrowser.Controller.Entities.TV.Series' And B.Guid in (Select AncestorId from AncestorIds where ItemId=A.Guid))");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (EnableGroupByPresentationUniqueKey(query))
|
if (EnableGroupByPresentationUniqueKey(query))
|
||||||
{
|
{
|
||||||
groups.Add("PresentationUniqueKey");
|
groups.Add("PresentationUniqueKey");
|
||||||
@ -1793,6 +1788,12 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||||||
|
|
||||||
var list = new List<BaseItem>();
|
var list = new List<BaseItem>();
|
||||||
|
|
||||||
|
// Hack for right now since we currently don't support filtering out these duplicates within a query
|
||||||
|
if (query.Limit.HasValue && query.EnableGroupByMetadataKey)
|
||||||
|
{
|
||||||
|
query.Limit = query.Limit.Value + 4;
|
||||||
|
}
|
||||||
|
|
||||||
using (var cmd = _connection.CreateCommand())
|
using (var cmd = _connection.CreateCommand())
|
||||||
{
|
{
|
||||||
cmd.CommandText = "select " + string.Join(",", GetFinalColumnsToSelect(query, _retriveItemColumns, cmd)) + GetFromText();
|
cmd.CommandText = "select " + string.Join(",", GetFinalColumnsToSelect(query, _retriveItemColumns, cmd)) + GetFromText();
|
||||||
@ -1845,9 +1846,57 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hack for right now since we currently don't support filtering out these duplicates within a query
|
||||||
|
if (query.EnableGroupByMetadataKey)
|
||||||
|
{
|
||||||
|
var limit = query.Limit ?? int.MaxValue;
|
||||||
|
limit -= 4;
|
||||||
|
var newList = new List<BaseItem>();
|
||||||
|
|
||||||
|
foreach (var item in list)
|
||||||
|
{
|
||||||
|
AddItem(newList, item);
|
||||||
|
|
||||||
|
if (newList.Count >= limit)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
list = newList;
|
||||||
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void AddItem(List<BaseItem> items, BaseItem newItem)
|
||||||
|
{
|
||||||
|
var providerIds = newItem.ProviderIds.ToList();
|
||||||
|
|
||||||
|
for (var i = 0; i < items.Count; i++)
|
||||||
|
{
|
||||||
|
var item = items[i];
|
||||||
|
|
||||||
|
foreach (var providerId in providerIds)
|
||||||
|
{
|
||||||
|
if (providerId.Key == MetadataProviders.TmdbCollection.ToString())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (item.GetProviderId(providerId.Key) == providerId.Value)
|
||||||
|
{
|
||||||
|
if (newItem.SourceType == SourceType.Library)
|
||||||
|
{
|
||||||
|
items[i] = newItem;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
items.Add(newItem);
|
||||||
|
}
|
||||||
|
|
||||||
private void LogQueryTime(string methodName, IDbCommand cmd, DateTime startDate)
|
private void LogQueryTime(string methodName, IDbCommand cmd, DateTime startDate)
|
||||||
{
|
{
|
||||||
var elapsed = (DateTime.UtcNow - startDate).TotalMilliseconds;
|
var elapsed = (DateTime.UtcNow - startDate).TotalMilliseconds;
|
||||||
|
@ -276,11 +276,6 @@ namespace MediaBrowser.Server.Mono.Native
|
|||||||
{
|
{
|
||||||
"https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/linux/ffmpeg-git-20160215-64bit-static.7z"
|
"https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/linux/ffmpeg-git-20160215-64bit-static.7z"
|
||||||
};
|
};
|
||||||
case Architecture.X86:
|
|
||||||
return new[]
|
|
||||||
{
|
|
||||||
"https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/linux/ffmpeg-git-20160215-32bit-static.7z"
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user