mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 12:33:03 +00:00
Restyle Implement Fuzzy search using rapidfuzz (#60)
This commit is contained in:
+18
-10
@@ -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,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user