-
-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multisearch #469
Open
michalmoc
wants to merge
16
commits into
epoupon:develop
Choose a base branch
from
michalmoc:multisearch
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Multisearch #469
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
2c6be94
There are cmake errors if libav is not found, so made it required. Al…
michalmoc 6753648
Basic multisearch interface.
michalmoc 4408246
First draft of multisearch output.
michalmoc ea96884
Minor fixes.
michalmoc 1f8bac6
Improvements to search results.
michalmoc c0170c8
ci fixes
michalmoc bcc72e4
Search engine for Multisearch
michalmoc d94cad8
Search engine takes into account active filters.
michalmoc 289bff6
Show only release artists on release list entry.
michalmoc 983cdc3
Keywords made into permanent table. Added colours to media type icons.
michalmoc 36eadcb
Settings to enable searchers.
michalmoc 5e42f70
Filter by entity type in multisearch.
michalmoc 94d761e
Merge remote-tracking branch 'origin/develop' into multisearch
michalmoc 31996f9
Reformat after merge.
michalmoc 6246c0b
Compilation fixes.
michalmoc aa2a089
Ui code refactor.
michalmoc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Search engine for Multisearch
- Loading branch information
commit bcc72e46dbb2dfcb14bd86ee16b281d993b0941d
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
add_library(lmsdatabase SHARED | ||
impl/AnyMedium.cpp | ||
impl/Artist.cpp | ||
impl/AuthToken.cpp | ||
impl/Cluster.cpp | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#include "database/AnyMedium.hpp" | ||
|
||
#include <database/Session.hpp> | ||
#include <tuple> | ||
|
||
#include "Utils.hpp" | ||
|
||
using namespace lms::db; | ||
|
||
namespace | ||
{ | ||
AnyMediumId fromString(const std::string &type, const Wt::Dbo::dbo_default_traits::IdType id) | ||
{ | ||
if (type == "artist") | ||
return ArtistId(id); | ||
if (type == "release") | ||
return ReleaseId(id); | ||
if (type == "track") | ||
return TrackId(id); | ||
|
||
throw std::logic_error("unknown medium type"); | ||
} | ||
} | ||
|
||
RangeResults<AnyMediumId> any_medium::findIds(Session &session, const std::vector<std::string_view> &keywords, std::optional<Range> range) | ||
{ | ||
using Columns = std::tuple<std::string, Wt::Dbo::dbo_default_traits::IdType, int>; | ||
|
||
session.checkReadTransaction(); | ||
|
||
auto query = session.getDboSession()->query<Columns>(R"( | ||
SELECT type, id, sum(weight) AS v | ||
FROM keywords | ||
)"); | ||
|
||
for (const std::string_view keyword : keywords) | ||
{ | ||
query.orWhere("value LIKE ? ESCAPE '" ESCAPE_CHAR_STR "'").bind("%" + utils::escapeLikeKeyword(keyword) + "%"); | ||
} | ||
|
||
query | ||
.groupBy("type, id") | ||
.orderBy("v DESC"); | ||
|
||
auto columns = utils::execRangeQuery<Columns>(query, range); | ||
auto results = std::vector<AnyMediumId>(columns.results.size()); | ||
|
||
for (const auto&[type, id, _] : columns.results) | ||
results.emplace_back(fromString(type, id)); | ||
|
||
return { | ||
columns.range, | ||
results, | ||
columns.moreResults | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#pragma once | ||
|
||
#include <variant> | ||
#include <vector> | ||
#include <optional> | ||
|
||
#include "ArtistId.hpp" | ||
#include "ReleaseId.hpp" | ||
#include "TrackId.hpp" | ||
#include "Types.hpp" | ||
|
||
namespace lms::db | ||
{ | ||
class Session; | ||
using AnyMediumId = std::variant<ArtistId, ReleaseId, TrackId>; | ||
|
||
namespace any_medium | ||
{ | ||
RangeResults<AnyMediumId> findIds(Session& session, const std::vector<std::string_view>& keywords, std::optional<Range> range); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check notice
Code scanning / CodeQL
Unused static function