Improve artist search
Replicate recent changes in title search to artist search
This commit is contained in:
parent
6d48bcc9d0
commit
b3905e062d
@ -704,13 +704,23 @@ class Tracks(Base):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def search_artists(cls, session: scoped_session, text: str) -> List["Tracks"]:
|
def search_artists(cls, session: scoped_session, text: str) -> List["Tracks"]:
|
||||||
"""Search case-insenstively for artists containing str"""
|
"""
|
||||||
|
Search case-insenstively for artists containing str
|
||||||
|
|
||||||
|
The query performs an outer join with 'joinedload' to populate the results
|
||||||
|
from the Playdates table at the same time. unique() needed; see
|
||||||
|
https://docs.sqlalchemy.org/en/20/orm/queryguide/relationships.html#joined-eager-loading
|
||||||
|
"""
|
||||||
|
|
||||||
return (
|
return (
|
||||||
session.execute(
|
session.execute(
|
||||||
select(cls).where(cls.artist.ilike(f"%{text}%")).order_by(cls.title)
|
select(cls)
|
||||||
|
.options(joinedload(Tracks.playdates))
|
||||||
|
.where(cls.artist.ilike(f"%{text}%"))
|
||||||
|
.order_by(cls.title)
|
||||||
)
|
)
|
||||||
.scalars()
|
.scalars()
|
||||||
|
.unique()
|
||||||
.all()
|
.all()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -1953,7 +1953,7 @@ class DbDialog(QDialog):
|
|||||||
if self.ui.radioTitle.isChecked():
|
if self.ui.radioTitle.isChecked():
|
||||||
matches = Tracks.search_titles(self.session, "%" + s)
|
matches = Tracks.search_titles(self.session, "%" + s)
|
||||||
else:
|
else:
|
||||||
matches = Tracks.search_artists(self.session, s)
|
matches = Tracks.search_artists(self.session, "%" + s)
|
||||||
if matches:
|
if matches:
|
||||||
for track in matches:
|
for track in matches:
|
||||||
last_played = None
|
last_played = None
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user