rewrite album and artist stores using in-mem hashmap stores

This commit is contained in:
cwilvx
2024-07-15 00:26:56 +03:00
parent 83e105a198
commit 58c90d95b1
11 changed files with 297 additions and 237 deletions
+5 -4
View File
@@ -1,8 +1,7 @@
# from tqdm import tqdm
import itertools
import sys
from typing import Callable
from typing import Callable, Iterable
from flask_jwt_extended import current_user
from app.db.libdata import TrackTable
from app.db.sqlite.favorite import SQLiteFavoriteMethods as favdb
@@ -243,7 +242,7 @@ class TrackStore:
# ================================================
@classmethod
def get_tracks_by_trackhashes(cls, trackhashes: list[str]) -> list[Track]:
def get_tracks_by_trackhashes(cls, trackhashes: Iterable[str]) -> list[Track]:
"""
Returns a list of tracks by their hashes.
"""
@@ -259,7 +258,9 @@ class TrackStore:
tracks.append(track)
# sort the tracks in the order of the given trackhashes
tracks.sort(key=lambda t: trackhashes.index(t.trackhash))
if type(trackhashes) == list:
tracks.sort(key=lambda t: trackhashes.index(t.trackhash))
return tracks
@classmethod