Skip to content

Commit bb01ca3

Browse files
committed
Merge branch 'develop'
2 parents c5a2ade + 9fb5bc8 commit bb01ca3

24 files changed

Lines changed: 914 additions & 445 deletions

.github/workflows/changelog.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
python-version: ${{ env.DEFAULT_PYTHON }}
3535

3636
- name: Install uv
37-
uses: astral-sh/setup-uv@v6
37+
uses: astral-sh/setup-uv@v7
3838

3939
- name: Install dependencies
4040
run: |

.github/workflows/codeql-analysis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
python-version: ${{ env.DEFAULT_PYTHON }}
3737

3838
- name: Install uv
39-
uses: astral-sh/setup-uv@v6
39+
uses: astral-sh/setup-uv@v7
4040

4141
- name: Install dependencies
4242
run: |
@@ -64,11 +64,11 @@ jobs:
6464

6565
# Initializes the CodeQL tools for scanning.
6666
- name: Initialize CodeQL
67-
uses: github/codeql-action/init@v3
67+
uses: github/codeql-action/init@v4
6868
with:
6969
languages: python
7070

7171
- name: Perform CodeQL Analysis
72-
uses: github/codeql-action/analyze@v3
72+
uses: github/codeql-action/analyze@v4
7373
with:
7474
category: /language:python

.github/workflows/dev-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
python-version: ${{ env.DEFAULT_PYTHON }}
4343

4444
- name: Install uv
45-
uses: astral-sh/setup-uv@v6
45+
uses: astral-sh/setup-uv@v7
4646

4747
- name: Fix logo in Readme
4848
run: |

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
run: sudo apt-get update && sudo apt-get install -y libldap2-dev libsasl2-dev
3838

3939
- name: Install uv
40-
uses: astral-sh/setup-uv@v6
40+
uses: astral-sh/setup-uv@v7
4141

4242
- name: Install dependencies
4343
run: |

.github/workflows/test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
python-version: ${{ env.DEFAULT_PYTHON }}
4343

4444
- name: Install uv
45-
uses: astral-sh/setup-uv@v6
45+
uses: astral-sh/setup-uv@v7
4646

4747
- name: Install dependencies
4848
run: |
@@ -76,7 +76,7 @@ jobs:
7676
dest: ./logs
7777

7878
- name: Upload Coverage Results
79-
uses: actions/upload-artifact@v4
79+
uses: actions/upload-artifact@v5
8080
with:
8181
name: raw-coverage-${{ env.DEFAULT_PYTHON }}
8282
path: reports/.coverage*
@@ -89,7 +89,7 @@ jobs:
8989
docker compose -f docker-compose.test.yml down -v --remove-orphans
9090
9191
- name: Upload DB logs
92-
uses: actions/upload-artifact@v4
92+
uses: actions/upload-artifact@v5
9393
if: failure()
9494
with:
9595
name: db-logs
@@ -123,7 +123,7 @@ jobs:
123123
run: pip install -I coverage
124124

125125
- name: Download all raw coverage data
126-
uses: actions/download-artifact@v5
126+
uses: actions/download-artifact@v6
127127
with:
128128
path: coverage-data/
129129
pattern: raw-coverage-*

.pre-commit-config.yaml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,18 @@ repos:
5151
- --no-extra-eol
5252

5353
- repo: https://github.com/asottile/pyupgrade
54-
rev: v3.20.0
54+
rev: v3.21.0
5555
hooks:
5656
- id: pyupgrade
5757
args: [--py37-plus, --keep-runtime-typing]
5858

5959
- repo: https://github.com/asottile/add-trailing-comma
60-
rev: v3.2.0
60+
rev: v4.0.0
6161
hooks:
6262
- id: add-trailing-comma
6363

6464
- repo: https://github.com/astral-sh/ruff-pre-commit
65-
rev: v0.13.3
65+
rev: v0.14.2
6666
hooks:
6767
- id: ruff-check
6868
args: [--fix]
@@ -88,10 +88,9 @@ repos:
8888
- tomli
8989

9090
- repo: https://github.com/astral-sh/uv-pre-commit
91-
rev: 0.8.23
91+
rev: 0.9.5
9292
hooks:
9393
- id: uv-lock
94-
args: [--prerelease=allow]
9594

9695
- repo: local
9796
hooks:

data_rentgen/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.4.1
1+
0.4.2

data_rentgen/db/repositories/run.py

Lines changed: 26 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,9 @@
66

77
from sqlalchemy import (
88
ColumnElement,
9-
CompoundSelect,
10-
Select,
11-
SQLColumnExpression,
12-
and_,
139
any_,
1410
bindparam,
11+
column,
1512
desc,
1613
func,
1714
select,
@@ -150,20 +147,35 @@ async def paginate( # noqa: PLR0912, C901, PLR0915
150147
if ended_until:
151148
where.append(Run.ended_at <= ended_until)
152149

153-
query: Select | CompoundSelect
154-
order_by: list[ColumnElement | SQLColumnExpression]
150+
run = select(Run).where(*where)
151+
152+
if job_types or job_location_ids:
153+
job = aliased(Job, name="job_type")
154+
run = run.join(job, Run.job_id == job.id)
155+
if job_types:
156+
where.append(job.type == any_(list(job_types))) # type: ignore[arg-type]
157+
if job_location_ids:
158+
where.append(job.location_id == any_(list(job_location_ids))) # type: ignore[arg-type]
159+
160+
if started_by_users:
161+
usernames_lower = [name.lower() for name in started_by_users]
162+
run = run.join(User, Run.started_by_user_id == User.id)
163+
where.append(func.lower(User.name) == any_(usernames_lower)) # type: ignore[arg-type]
164+
165+
query = run.where(*where)
166+
order_by: list[ColumnElement] = [desc("created_at"), desc("id")]
155167
if search_query:
156168
tsquery = make_tsquery(search_query)
157169

158-
run_stmt = select(Run, ts_rank(Run.search_vector, tsquery).label("search_rank")).where(
159-
ts_match(Run.search_vector, tsquery),
160-
*where,
170+
run_cte = query.cte()
171+
run_stmt = select(run_cte, ts_rank(column("search_vector"), tsquery).label("search_rank")).where(
172+
ts_match(column("search_vector"), tsquery),
161173
)
162174
job_search = aliased(Job, name="job_search")
163175
job_stmt = (
164-
select(Run, ts_rank(job_search.search_vector, tsquery).label("search_rank"))
165-
.join(job_search, job_search.id == Run.job_id)
166-
.where(ts_match(job_search.search_vector, tsquery), *where)
176+
select(run_cte, ts_rank(job_search.search_vector, tsquery).label("search_rank"))
177+
.join(job_search, job_search.id == column("job_id"))
178+
.where(ts_match(job_search.search_vector, tsquery))
167179
)
168180

169181
union_cte = union(run_stmt, job_stmt).cte()
@@ -176,27 +188,6 @@ async def paginate( # noqa: PLR0912, C901, PLR0915
176188
).group_by(*run_columns)
177189
# place the most recent runs on top
178190
order_by = [desc("search_rank"), desc("created_at"), desc("id")]
179-
else:
180-
query = select(Run).where(*where)
181-
order_by = [Run.created_at.desc(), Run.id.desc()]
182-
183-
if job_types or job_location_ids:
184-
job = aliased(Job, name="job_type")
185-
query = query.join(job, and_(Run.job_id == job.id))
186-
if job_types:
187-
query = query.where(job.type == any_(list(job_types))) # type: ignore[arg-type]
188-
if job_location_ids:
189-
query = query.where(job.location_id == any_(list(job_location_ids))) # type: ignore[arg-type]
190-
191-
if started_by_users:
192-
usernames_lower = [name.lower() for name in started_by_users]
193-
query = query.join(
194-
User,
195-
and_(
196-
Run.started_by_user_id == User.id,
197-
func.lower(User.name) == any_(usernames_lower), # type: ignore[arg-type]
198-
),
199-
)
200191

201192
options = [selectinload(Run.started_by_user)]
202193
return await self._paginate_by_query(
@@ -308,9 +299,9 @@ async def update(
308299
"persistent_log_url": new.persistent_log_url,
309300
"running_log_url": new.running_log_url,
310301
}
311-
for column, value in optional_fields.items():
302+
for col_name, value in optional_fields.items():
312303
if value is not None:
313-
setattr(existing, column, value)
304+
setattr(existing, col_name, value)
314305

315306
await self._session.flush([existing])
316307
return existing

data_rentgen/db/utils/search.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from string import punctuation
66

77
from sqlalchemy import ColumnElement, func
8-
from sqlalchemy.orm import InstrumentedAttribute
8+
from sqlalchemy.sql import SQLColumnExpression
99

1010
# left some punctuation to match file paths, URLs and host names
1111
TSQUERY_UNSUPPORTED_CHARS = "".join(sorted(set(punctuation) - {"/", ".", "_", "-"}))
@@ -25,7 +25,7 @@ class SearchRankNormalization(IntFlag):
2525
RANK_PLUS_ONE = 32
2626

2727

28-
def ts_rank(search_vector: InstrumentedAttribute, ts_query: ColumnElement) -> ColumnElement:
28+
def ts_rank(search_vector: SQLColumnExpression, ts_query: ColumnElement) -> ColumnElement:
2929
"""Get ts_rank for search query ranking.
3030
3131
Places results with smaller number of total words (like table name) to the top,
@@ -48,7 +48,7 @@ def make_tsquery(user_input: str) -> ColumnElement:
4848
return func.to_tsquery("simple", build_tsquery(user_input))
4949

5050

51-
def ts_match(search_vector: InstrumentedAttribute, ts_query: ColumnElement) -> ColumnElement:
51+
def ts_match(search_vector: SQLColumnExpression, ts_query: ColumnElement) -> ColumnElement:
5252
"""Build an expression to get only search_vector matching ts_query."""
5353
return search_vector.op("@@")(ts_query)
5454

docs/changelog/0.4.2.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
0.4.2 (2025-10-29)
2+
=================
3+
4+
Bug fixes
5+
---------
6+
7+
- Fix search query filter on UI Run list page.
8+
- Fix passing multiple filters to ``GET /v1/runs``.
9+
10+
Doc only Changes
11+
----------------
12+
13+
- Document ``DATA_RENTGEN__UI__AUTH_PROVIDER`` config variable.

0 commit comments

Comments
 (0)