Restyle Implement Fuzzy search using rapidfuzz (#60)

This commit is contained in:
restyled-io[bot]
2022-05-26 19:12:04 +03:00
committed by GitHub
parent 1a3a196d7a
commit 2b33fb87a2
15 changed files with 90 additions and 74 deletions
+18 -10
View File
@@ -1,11 +1,10 @@
"""
Contains all the search routes.
"""
from flask import Blueprint, request
from app.lib import searchlib
from app import helpers
from app.lib import searchlib
from flask import Blueprint
from flask import request
search_bp = Blueprint("search", __name__, url_prefix="/")
@@ -96,9 +95,18 @@ def search():
return {
"data": [
{"tracks": tracks[:5], "more": len(tracks) > 5},
{"albums": albums[:6], "more": len(albums) > 6},
{"artists": artists_dicts[:6], "more": len(artists_dicts) > 6},
{
"tracks": tracks[:5],
"more": len(tracks) > 5
},
{
"albums": albums[:6],
"more": len(albums) > 6
},
{
"artists": artists_dicts[:6],
"more": len(artists_dicts) > 6
},
]
}
@@ -116,18 +124,18 @@ def search_load_more():
if type == "tracks":
return {
"tracks": SEARCH_RESULTS["tracks"][index : index + 5],
"tracks": SEARCH_RESULTS["tracks"][index:index + 5],
"more": len(SEARCH_RESULTS["tracks"]) > index + 5,
}
elif type == "albums":
return {
"albums": SEARCH_RESULTS["albums"][index : index + 6],
"albums": SEARCH_RESULTS["albums"][index:index + 6],
"more": len(SEARCH_RESULTS["albums"]) > index + 6,
}
elif type == "artists":
return {
"artists": SEARCH_RESULTS["artists"][index : index + 6],
"artists": SEARCH_RESULTS["artists"][index:index + 6],
"more": len(SEARCH_RESULTS["artists"]) > index + 6,
}