Commit graph

12644 commits

Author SHA1 Message Date
Šarūnas Nejus
1f93207823
Add any_writable_field_query to fix bpd search 2024-06-16 15:28:46 +01:00
Šarūnas Nejus
6792a75c7e
Ensure that any field query uses the table name
In order to include the table name for fields in this query, use the
`field_query` method.

Since `AnyFieldQuery` is just an `OrQuery` under the hood, remove it and
construct `OrQuery` explicitly instead.
2024-06-16 15:28:46 +01:00
Šarūnas Nejus
e0c50c5501
Remove slow lookups from beetsplug/aura
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.
2024-06-16 15:28:46 +01:00
Šarūnas Nejus
9207b17d13
Enable querying related flexible attributes
Unify query creation logic from
- queryparse.py:construct_query_part,
- Model.field_query,
- DefaultTemplateFunctions._tmpl_unique

to a single implementation under `LibModel.field_query` class method.
This method should be used for query resolution for model (flex)fields.

Allow filtering item attributes in album queries and vice versa by
merging `flex_attrs` from Album and Item together as `all_flex_attrs`.
This field is only used for filtering and is discarded after.
2024-06-16 15:28:46 +01:00
Šarūnas Nejus
484c00e223
Add ability to filter flexible attributes through the Query
For a flexible attribute query, replace the `col_name` property with
a function call that extracts that attribute from the `field_attrs`
field introduced in the earlier commit.

Additionally, for boolean, numeric and date queries CAST the value to
NUMERIC SQLite affinity to ensure that our queries like 'flex:1..5' and
'flex:true' continue working fine.

This removes the concept of 'slow query', since every query for any
field now has an SQL clause.
2024-06-16 15:28:46 +01:00
Šarūnas Nejus
969d847110
Aggregate flexible attributes
Use `json_group_object` SQLite function to aggregate flexible attributes
into `flex_attrs` field.

Register SQLite converter `json.loads` to automatically convert the JSON
string to a Python dictionary. Remove the code that had this task
previously.
2024-06-16 15:28:46 +01:00
Šarūnas Nejus
b0154d5cde
Fix querying fields present in both tables 2024-06-16 15:28:45 +01:00
Šarūnas Nejus
1862c7367b
Add ability to debug queries 2024-06-16 15:28:45 +01:00
Šarūnas Nejus
3347020c6c
Add support for filtering relations 2024-06-16 15:28:45 +01:00
Šarūnas Nejus
265e40b14e
Make LazyClassProperty / cached_classproperty reusable 2024-06-16 14:20:07 +01:00
Šarūnas Nejus
0e87389994
Replace py3_path and cpu_count implementations with builtins (#5227)
Replace py3_path by standard os.fsdecode and use native os.cpu_count.

These functions had been written before builtins achieving the same have
been made available (in Python 3.2 and 3.4). 

Now that they are available though, this PR updates the codebase to use
builtin implementations rather than the custom ones.
2024-06-16 11:50:27 +01:00
Šarūnas Nejus
6b63a3090d
Remove flake8 docstrings and its exclusion rules (#5234) 2024-06-16 02:55:49 +01:00
Šarūnas Nejus
076ec6f773
Do not run coverage by default (#5312)
Fixes #5242.

This PR moves coverage measurement from the default `pytest` invocation
to a separate action `test-with-coverage`.
2024-06-16 01:32:59 +01:00
Šarūnas Nejus
19470f3d76
Use native os.cpu_count
os.cpu_count has only been available since Python 3.4
2024-06-16 00:52:38 +01:00
Šarūnas Nejus
f388ff6ec1
Replace py3_path with builtin os.fsdecode
`os.fsdecode` has only been available since Python 3.2.
2024-06-16 00:52:37 +01:00
Šarūnas Nejus
0e1b5c20ed
Gitignore the .reports directory 2024-06-15 23:52:52 +01:00
Šarūnas Nejus
3e075f2a9a
Add 'test-with-coverage' command
And do not measure coverage by default.
2024-06-15 23:52:18 +01:00
Šarūnas Nejus
fa788e2e5a
Remove flake8-docstrings and its exclusion rules 2024-06-15 13:09:33 +01:00
Šarūnas Nejus
494c67603a
Fix running tests with/without coverage (#5309)
Apparently the `!` operator does not exist in GitHub Actions.

Also fix coverage upload.
2024-06-15 10:15:53 +01:00
Šarūnas Nejus
30d345dd7d
Try fixing coverage 2024-06-15 10:07:29 +01:00
Serene
bbb9aad6fa
Update release workflow with poetry (#5308) 2024-06-15 18:56:08 +10:00
Šarūnas Nejus
49e6012398
Try fixing testing workflow 2024-06-15 09:19:54 +01:00
Šarūnas Nejus
190198bfa6
Make make-github-release job dependent on publish-to-pypi 2024-06-15 08:48:13 +01:00
Šarūnas Nejus
8b52f3f9a5
Release workflow: Move changelog retrieval to the build job 2024-06-15 06:35:01 +01:00
Šarūnas Nejus
ed574f4307
Release workflow: Update external GitHub action versions
This fixes three warnings seen on https://github.com/beetbox/beets/actions/runs/9296798803
2024-06-15 06:35:01 +01:00
Šarūnas Nejus
1f8c5b8b33
Release workflow: Use poe changelog in make-github-release job 2024-06-15 04:25:51 +01:00
Šarūnas Nejus
0a1bddd99e
Release workflow: Use poetry to build the package 2024-06-15 04:25:51 +01:00
Šarūnas Nejus
f964aa89c9
Release workflow: use poe bump to bump the version 2024-06-15 04:25:51 +01:00
Šarūnas Nejus
e3075b76e0
Move dependencies required for release to a separate group 2024-06-15 04:25:50 +01:00
Serene
54a8ef7a32
Fix changelog reminder workflow (#5305)
Quote the breaking glob as noted by @bal-e.
2024-06-15 12:23:06 +10:00
Serene
8a28fd5707
Remove the beet executable and update shebangs (#5303)
## Description

This is a very simple PR, just removing the (apparently unused) `beet`
executable from the repository and substituting `bin/env python` for
`bin/python3` where possible.

Fixes #4604.
2024-06-15 11:11:50 +10:00
Serene
461a1c6f91
Make the release send a toot on Fosstodon (#5302)
This adds a step to the GitHub release so that it sends a toot on
Fosstodon, beets' Mastodon account, to publicise that and get some
engagement!

Not tested, but this is lifted straight from the action repo so it
*should* be okay. @snejus for a sanity check if you wouldn't mind
2024-06-15 10:02:47 +10:00
Serene
aacf983268
Remove release script from pyproject (#5307)
I realised that when users install beets, this `release` script would
also get installed for them, which is not ideal, I guess.
2024-06-15 09:57:36 +10:00
Šarūnas Nejus
db1b72fced
Fix black security vulnerability (#5306)
See https://github.com/beetbox/beets/security/dependabot/7
2024-06-14 20:53:50 +01:00
Šarūnas Nejus
09b67c1da6
Ignore aura.py/flake8-docstrings 2024-06-14 20:12:19 +01:00
Šarūnas Nejus
a3721fea81
Check all Python files when poetry.lock changes 2024-06-14 20:12:19 +01:00
Šarūnas Nejus
8608b2549b
Trigger lint workflow on dependency updates 2024-06-14 18:49:39 +01:00
Šarūnas Nejus
e7ece96268
Remove release script from pyproject
I realised that when users install beets, this `release` script would
also get installed for them, which is not ideal, I guess.
2024-06-14 16:27:40 +01:00
Šarūnas Nejus
b29c9a83b9
Upgrade black, pin it below v25 2024-06-14 16:16:51 +01:00
Šarūnas Nejus
249d49942e
Make a change to test 2024-06-14 16:04:15 +01:00
Šarūnas Nejus
040a2412b3
Quote changed files glob 2024-06-14 16:00:36 +01:00
Arav K.
8b3890bb4d [changelog] note the removal of the 'beet' script 2024-06-14 14:55:06 +02:00
Arav K.
0b10d84862 Explicitly use Python 3 for scripts
While Python 2 is long dead, and a 'bin/env python' shebang is probably
perfectly fine, this is just a bit safer.

See <https://github.com/beetbox/beets/issues/4604>.
2024-06-14 14:44:29 +02:00
Arav K.
0b517fc4c9 Remove the 'beet' wrapper script
Apparently, this script isn't actually used for anything; the build
system will automatically generate a script like this when installing
`beets`.

See <https://github.com/beetbox/beets/issues/4604>.
2024-06-14 14:41:40 +02:00
Serene
0c96da1136
Use output of tagging action in message
Co-authored-by: Šarūnas Nejus <snejus@protonmail.com>
2024-06-14 21:51:29 +10:00
Serene
c7da94152f
Fix changelog workflow (#5231)
Use `pull_request_target` event for the changelog update reminder
2024-06-14 20:40:52 +10:00
Serene-Arc
d03b1af90d
Add mastodon step to release step 2024-06-14 18:52:08 +10:00
Šarūnas Nejus
b583fb7dec
Resolve some 'mypy' errors (#5282)
## Description

I noticed that some development work was waiting on cleaner `mypy` runs,
so I thought I would help out a bit. This PR just contains a number of
miscellaneous fixes across the codebase that I hit. I'm happy to add
more, or remove any problematic changes (though I don't think I've
broken anything, only type annotations have changed).

## To Do

- [x] ~Documentation~
- [ ] Changelog
- [x] ~Tests~
2024-06-13 14:41:35 +01:00
Serene
1f671fcc38
Update the bash completion script (#5301)
Some functions used by the bash completion script have become
deprecated. This was causing the test suite to break on faster-moving
distributions (e.g. Arch Linux and Gentoo). The issue is only noticeable
because the tests for the completion function explicitly disallow
compatibility implementations from being loaded. Rather than allowing
compatibility implementations, I've added some basic logic to the
completion script so that older and newer versions of `bash-completion`
can be supported simultaneously.
2024-06-13 17:56:45 +10:00
Arav K.
9ca8f24189 Require 'bash-completion' >=v2.8 instead of v2.10
Debian 10 LTS only has 'bash-completion' v2.8, but support for it
expires at the end of the month (2024-06-30).  Still, this completion
script apparently worked there, so there's no harm in reducing the
version requirement, which I had previously picked arbitrarily.

See https://github.com/beetbox/beets/pull/5301#issuecomment-2164297308.
2024-06-13 09:19:12 +02:00