Skip to content

Commit 9a0656b

Browse files
committed
Add get_by_backend_job_id method to QueueJobStore
Allows looking up a QueueJob by its arq backend job ID, which is needed for the worker to find and update the corresponding QueueJob record.
1 parent ffc2edf commit 9a0656b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/docverse/storage/queue_job_store.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,20 @@ async def get_by_public_id(self, public_id: int) -> QueueJob | None:
7676
return None
7777
return QueueJob.model_validate(row, from_attributes=True)
7878

79+
async def get_by_backend_job_id(
80+
self, backend_job_id: str
81+
) -> QueueJob | None:
82+
"""Fetch a QueueJob by its arq backend job ID."""
83+
result = await self._session.execute(
84+
select(SqlQueueJob).where(
85+
SqlQueueJob.backend_job_id == backend_job_id
86+
)
87+
)
88+
row = result.scalar_one_or_none()
89+
if row is None:
90+
return None
91+
return QueueJob.model_validate(row, from_attributes=True)
92+
7993
async def start(self, job_id: int) -> QueueJob:
8094
"""Mark job as in_progress, set date_started=now().
8195

0 commit comments

Comments
 (0)