Skip to content

Commit

Permalink
Remove slow lookups from beetsplug/aura
Browse files Browse the repository at this point in the history
It seems like previously filtering by flexible attributes did not work
- I'd receive '{"data": []}' trying to GET `/aura/tracks?filter[play_count]=11`

Now this works, not only for tracks, but for `/aura/artists` and
`/aura/albums` too.

Additionally, this improves `/aura/tracks` response time significantly.
I tried loading the default of 500 tracks from my library:

On `master`, it took ~20s
After this commit, it takes under 1s.
  • Loading branch information
snejus committed May 8, 2024
1 parent de85dd1 commit ad2ea5a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions beetsplug/aura.py
Expand Up @@ -182,8 +182,9 @@ def translate_filters(self):
converter = self.get_attribute_converter(beets_attr)
value = converter(value)
# Add exact match query to list
# Use a slow query so it works with all fields
queries.append(MatchQuery(beets_attr, value, fast=False))
queries.append(
self.model_cls.field_query(beets_attr, value, MatchQuery)
)
# NOTE: AURA doesn't officially support multiple queries
return AndQuery(queries)

Expand Down

0 comments on commit ad2ea5a

Please sign in to comment.