fix user data queries

pull/702/head
Luke Pulverenti 8 years ago
parent 2d6954f520
commit 192cbe34aa

@ -156,8 +156,6 @@ namespace MediaBrowser.Server.Implementations.Persistence
"create index if not exists idx_AncestorIds2 on AncestorIds(AncestorIdText)",
"create table if not exists UserDataKeys (ItemId GUID, UserDataKey TEXT Priority INT, PRIMARY KEY (ItemId, UserDataKey))",
//"create index if not exists idx_UserDataKeys1 on UserDataKeys(ItemId)",
"create index if not exists idx_UserDataKeys2 on UserDataKeys(ItemId,Priority)",
"create table if not exists ItemValues (ItemId GUID, Type INT, Value TEXT, CleanValue TEXT)",
//"create index if not exists idx_ItemValues on ItemValues(ItemId)",
@ -294,7 +292,10 @@ namespace MediaBrowser.Server.Implementations.Persistence
"create index if not exists idx_TypeTopParentId7 on TypedBaseItems(TopParentId,MediaType,IsVirtualItem,PresentationUniqueKey)",
// items by name
"create index if not exists idx_ItemValues3 on ItemValues(ItemId,Type,CleanValue)"
"create index if not exists idx_ItemValues3 on ItemValues(ItemId,Type,CleanValue)",
//"create index if not exists idx_UserDataKeys1 on UserDataKeys(ItemId)",
"create index if not exists idx_UserDataKeys2 on UserDataKeys(ItemId,Priority)"
};
_connection.RunQueries(postQueries, Logger);
@ -1712,7 +1713,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
return string.Empty;
}
return " left join UserDataDb.UserData on (select UserDataKey from UserDataKeys where ItemId=Guid order by Priority LIMIT 1)=UserDataDb.UserData.Key";
return " left join UserDataDb.UserData on (select UserDataKey from UserDataKeys where ItemId=Guid order by Priority LIMIT 1)=UserDataDb.UserData.Key And (UserId=@UserId)";
}
private string GetGroupBy(InternalItemsQuery query)
@ -1961,11 +1962,11 @@ namespace MediaBrowser.Server.Implementations.Persistence
{
if (query.User != null)
{
query.SortBy = new[] { "SimilarityScore", "IsPlayed", "Random" };
query.SortBy = new[] { "SimilarityScore", ItemSortBy.IsPlayed, ItemSortBy.Random };
}
else
{
query.SortBy = new[] { "SimilarityScore", "Random" };
query.SortBy = new[] { "SimilarityScore", ItemSortBy.Random };
}
query.SortOrder = SortOrder.Descending;
}
@ -2296,7 +2297,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
if (EnableJoinUserData(query))
{
whereClauses.Add("(UserId is null or UserId=@UserId)");
//whereClauses.Add("(UserId is null or UserId=@UserId)");
}
if (query.IsCurrentSchema.HasValue)
{

@ -66,6 +66,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
"create index if not exists idx_userdata on userdata(key)",
"create unique index if not exists userdataindex on userdata (key, userId)",
"create index if not exists userdataindex1 on userdata (key, userId)",
//pragmas
"pragma temp_store = memory",

@ -647,7 +647,7 @@ namespace MediaBrowser.Server.Startup.Common
/// <returns>Task.</returns>
private async Task RegisterMediaEncoder(IProgress<double> progress)
{
var info = await new FFMpegLoader(Logger, ApplicationPaths, HttpClient, ZipClient, FileSystemManager, NativeApp.Environment, NativeApp.GetType().Assembly, NativeApp.GetFfmpegInstallInfo())
var info = await new FFMpegLoader(Logger, ApplicationPaths, HttpClient, ZipClient, FileSystemManager, NativeApp.Environment, NativeApp.GetFfmpegInstallInfo())
.GetFFMpegInfo(NativeApp.Environment, _startupOptions, progress).ConfigureAwait(false);
_hasExternalEncoder = string.Equals(info.Version, "custom", StringComparison.OrdinalIgnoreCase);

@ -24,7 +24,6 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
private readonly IZipClient _zipClient;
private readonly IFileSystem _fileSystem;
private readonly NativeEnvironment _environment;
private readonly Assembly _ownerAssembly;
private readonly FFMpegInstallInfo _ffmpegInstallInfo;
private readonly string[] _fontUrls =
@ -32,7 +31,7 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
"https://github.com/MediaBrowser/MediaBrowser.Resources/raw/master/ffmpeg/ARIALUNI.7z"
};
public FFMpegLoader(ILogger logger, IApplicationPaths appPaths, IHttpClient httpClient, IZipClient zipClient, IFileSystem fileSystem, NativeEnvironment environment, Assembly ownerAssembly, FFMpegInstallInfo ffmpegInstallInfo)
public FFMpegLoader(ILogger logger, IApplicationPaths appPaths, IHttpClient httpClient, IZipClient zipClient, IFileSystem fileSystem, NativeEnvironment environment, FFMpegInstallInfo ffmpegInstallInfo)
{
_logger = logger;
_appPaths = appPaths;
@ -40,7 +39,6 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
_zipClient = zipClient;
_fileSystem = fileSystem;
_environment = environment;
_ownerAssembly = ownerAssembly;
_ffmpegInstallInfo = ffmpegInstallInfo;
}
@ -99,14 +97,8 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
}
else
{
// Older version found.
// Start with that. Download new version in the background.
var newPath = versionedDirectoryPath;
Task.Run(() => DownloadFFMpegInBackground(downloadInfo, newPath));
info = existingVersion;
versionedDirectoryPath = Path.GetDirectoryName(info.EncoderPath);
excludeFromDeletions.Add(versionedDirectoryPath);
}
}

Loading…
Cancel
Save