From cfe78d820c5fc553d1d7211531258f319dd36700 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Tue, 11 Feb 2020 00:23:28 +0100 Subject: [PATCH] Solving a bug with the search query --- Kyoo/Controllers/LibraryManager.cs | 7 +++---- Kyoo/HtmlAPI/SearchAPI.cs | 14 +++++++------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Kyoo/Controllers/LibraryManager.cs b/Kyoo/Controllers/LibraryManager.cs index 12c6b93e..96dc6d5d 100644 --- a/Kyoo/Controllers/LibraryManager.cs +++ b/Kyoo/Controllers/LibraryManager.cs @@ -67,10 +67,9 @@ namespace Kyoo.Controllers public IEnumerable GetShows(string searchQuery) { - return (from show in _database.Shows join link in _database.CollectionLinks on show equals link.Show into gj - from l in gj.DefaultIfEmpty() - where l.CollectionID == null select l.Show).Union( - from collection in _database.Collections select collection.AsShow()) + return (from show in _database.Shows from l in _database.CollectionLinks.DefaultIfEmpty() + where l.CollectionID == null select show).AsEnumerable().Union( + from collection in _database.Collections select collection.AsShow()) .Where(x => x.Title.Contains(searchQuery)).OrderBy(x => x.Title); } diff --git a/Kyoo/HtmlAPI/SearchAPI.cs b/Kyoo/HtmlAPI/SearchAPI.cs index 6a33330f..f7527791 100644 --- a/Kyoo/HtmlAPI/SearchAPI.cs +++ b/Kyoo/HtmlAPI/SearchAPI.cs @@ -8,11 +8,11 @@ namespace Kyoo.Controllers [ApiController] public class SearchController : ControllerBase { - private readonly ILibraryManager libraryManager; + private readonly ILibraryManager _libraryManager; public SearchController(ILibraryManager libraryManager) { - this.libraryManager = libraryManager; + _libraryManager = libraryManager; } [HttpGet("{query}")] @@ -21,11 +21,11 @@ namespace Kyoo.Controllers SearchResult result = new SearchResult { Query = query, - Shows = libraryManager.GetShows(query), - Episodes = libraryManager.SearchEpisodes(query), - People = libraryManager.SearchPeople(query), - Genres = libraryManager.SearchGenres(query), - Studios = libraryManager.SearchStudios(query) + Shows = _libraryManager.GetShows(query), + Episodes = _libraryManager.SearchEpisodes(query), + People = _libraryManager.SearchPeople(query), + Genres = _libraryManager.SearchGenres(query), + Studios = _libraryManager.SearchStudios(query) }; return result; }