queuerPy 0.4.0__tar.gz → 0.6.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. {queuerpy-0.4.0/queuerPy.egg-info → queuerpy-0.6.0}/PKG-INFO +3 -24
  2. {queuerpy-0.4.0 → queuerpy-0.6.0}/README.md +2 -23
  3. {queuerpy-0.4.0 → queuerpy-0.6.0}/_version.py +1 -1
  4. {queuerpy-0.4.0 → queuerpy-0.6.0}/database/db_job.py +53 -287
  5. queuerpy-0.6.0/database/db_master.py +134 -0
  6. {queuerpy-0.4.0 → queuerpy-0.6.0}/database/db_worker.py +13 -99
  7. {queuerpy-0.4.0 → queuerpy-0.6.0}/helper/sql.py +48 -1
  8. {queuerpy-0.4.0 → queuerpy-0.6.0}/model/job.py +41 -30
  9. queuerpy-0.6.0/model/master.py +106 -0
  10. {queuerpy-0.4.0 → queuerpy-0.6.0}/model/worker.py +3 -3
  11. {queuerpy-0.4.0 → queuerpy-0.6.0}/pyproject.toml +1 -1
  12. {queuerpy-0.4.0 → queuerpy-0.6.0}/queuer.py +8 -2
  13. {queuerpy-0.4.0 → queuerpy-0.6.0/queuerPy.egg-info}/PKG-INFO +3 -24
  14. {queuerpy-0.4.0 → queuerpy-0.6.0}/queuerPy.egg-info/SOURCES.txt +6 -0
  15. {queuerpy-0.4.0 → queuerpy-0.6.0}/queuer_global.py +10 -1
  16. {queuerpy-0.4.0 → queuerpy-0.6.0}/queuer_job.py +16 -5
  17. queuerpy-0.6.0/queuer_master.py +163 -0
  18. queuerpy-0.6.0/sql/job.sql +814 -0
  19. queuerpy-0.6.0/sql/master.sql +99 -0
  20. {queuerpy-0.4.0 → queuerpy-0.6.0}/sql/notify.sql +11 -2
  21. {queuerpy-0.4.0 → queuerpy-0.6.0}/sql/worker.sql +146 -0
  22. queuerpy-0.4.0/sql/job.sql +0 -373
  23. {queuerpy-0.4.0 → queuerpy-0.6.0}/LICENSE +0 -0
  24. {queuerpy-0.4.0 → queuerpy-0.6.0}/MANIFEST.in +0 -0
  25. {queuerpy-0.4.0 → queuerpy-0.6.0}/__init__.py +0 -0
  26. {queuerpy-0.4.0 → queuerpy-0.6.0}/core/__init__.py +0 -0
  27. {queuerpy-0.4.0 → queuerpy-0.6.0}/core/broadcaster.py +0 -0
  28. {queuerpy-0.4.0 → queuerpy-0.6.0}/core/listener.py +0 -0
  29. {queuerpy-0.4.0 → queuerpy-0.6.0}/core/retryer.py +0 -0
  30. {queuerpy-0.4.0 → queuerpy-0.6.0}/core/runner.py +0 -0
  31. {queuerpy-0.4.0 → queuerpy-0.6.0}/core/scheduler.py +0 -0
  32. {queuerpy-0.4.0 → queuerpy-0.6.0}/core/ticker.py +0 -0
  33. {queuerpy-0.4.0 → queuerpy-0.6.0}/database/__init__.py +0 -0
  34. {queuerpy-0.4.0 → queuerpy-0.6.0}/database/db_listener.py +0 -0
  35. {queuerpy-0.4.0 → queuerpy-0.6.0}/helper/__init__.py +0 -0
  36. {queuerpy-0.4.0 → queuerpy-0.6.0}/helper/database.py +0 -0
  37. {queuerpy-0.4.0 → queuerpy-0.6.0}/helper/error.py +0 -0
  38. {queuerpy-0.4.0 → queuerpy-0.6.0}/helper/logging.py +0 -0
  39. {queuerpy-0.4.0 → queuerpy-0.6.0}/helper/task.py +0 -0
  40. {queuerpy-0.4.0 → queuerpy-0.6.0}/model/__init__.py +0 -0
  41. {queuerpy-0.4.0 → queuerpy-0.6.0}/model/batch_job.py +0 -0
  42. {queuerpy-0.4.0 → queuerpy-0.6.0}/model/connection.py +0 -0
  43. {queuerpy-0.4.0 → queuerpy-0.6.0}/model/options.py +0 -0
  44. {queuerpy-0.4.0 → queuerpy-0.6.0}/model/options_on_error.py +0 -0
  45. {queuerpy-0.4.0 → queuerpy-0.6.0}/model/task.py +0 -0
  46. {queuerpy-0.4.0 → queuerpy-0.6.0}/queuerPy.egg-info/dependency_links.txt +0 -0
  47. {queuerpy-0.4.0 → queuerpy-0.6.0}/queuerPy.egg-info/requires.txt +0 -0
  48. {queuerpy-0.4.0 → queuerpy-0.6.0}/queuerPy.egg-info/top_level.txt +0 -0
  49. {queuerpy-0.4.0 → queuerpy-0.6.0}/queuer_listener.py +0 -0
  50. {queuerpy-0.4.0 → queuerpy-0.6.0}/queuer_next_interval.py +0 -0
  51. {queuerpy-0.4.0 → queuerpy-0.6.0}/queuer_task.py +0 -0
  52. {queuerpy-0.4.0 → queuerpy-0.6.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: queuerPy
3
- Version: 0.4.0
3
+ Version: 0.6.0
4
4
  Summary: A Python implementation of the queuer system - a job queuing and processing system with PostgreSQL backend
5
5
  Author-email: Simon Herrmann <siherrmann@users.noreply.github.com>
6
6
  Maintainer-email: Simon Herrmann <siherrmann@users.noreply.github.com>
@@ -45,7 +45,7 @@ Dynamic: license-file
45
45
 
46
46
  [![Python](https://img.shields.io/badge/Python-3.10+-blue.svg)](https://www.python.org/)
47
47
  [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/siherrmann/queuer/blob/master/LICENSE)
48
- ![Coverage](./coverage-badge.svg)
48
+ ![Coverage](https://raw.githubusercontent.com/siherrmann/queuerPy/refs/heads/main/coverage-badge.svg)
49
49
 
50
50
  Python port of the queuer package - a queueing system based on PostgreSQL.
51
51
 
@@ -62,28 +62,7 @@ The job table contains only queued, scheduled and running tasks. The ended jobs
62
62
  ## PyPI Installation (Recommended)
63
63
 
64
64
  ```bash
65
- pip install queuer-py
66
- ```
67
-
68
- For development dependencies:
69
- ```bash
70
- pip install queuer-py[dev]
71
- ```
72
-
73
- ## Development Installation
74
-
75
- To integrate the queuer package into your Python project for development:
76
-
77
- ```bash
78
- # Clone the repository
79
- git clone https://github.com/siherrmann/queuerPy.git
80
- cd queuerPy
81
-
82
- # Install in development mode
83
- pip install -e .
84
-
85
- # Or with development dependencies
86
- pip install -e .[dev]
65
+ pip install queuerPy
87
66
  ```
88
67
 
89
68
  To use the package you also need a running postgres database with the timescaleDB extension. You can use the `docker-compose.yml` file in the example folder or start a Docker container with the `timescale/timescaledb:latest-pg17` image.
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![Python](https://img.shields.io/badge/Python-3.10+-blue.svg)](https://www.python.org/)
4
4
  [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/siherrmann/queuer/blob/master/LICENSE)
5
- ![Coverage](./coverage-badge.svg)
5
+ ![Coverage](https://raw.githubusercontent.com/siherrmann/queuerPy/refs/heads/main/coverage-badge.svg)
6
6
 
7
7
  Python port of the queuer package - a queueing system based on PostgreSQL.
8
8
 
@@ -19,28 +19,7 @@ The job table contains only queued, scheduled and running tasks. The ended jobs
19
19
  ## PyPI Installation (Recommended)
20
20
 
21
21
  ```bash
22
- pip install queuer-py
23
- ```
24
-
25
- For development dependencies:
26
- ```bash
27
- pip install queuer-py[dev]
28
- ```
29
-
30
- ## Development Installation
31
-
32
- To integrate the queuer package into your Python project for development:
33
-
34
- ```bash
35
- # Clone the repository
36
- git clone https://github.com/siherrmann/queuerPy.git
37
- cd queuerPy
38
-
39
- # Install in development mode
40
- pip install -e .
41
-
42
- # Or with development dependencies
43
- pip install -e .[dev]
22
+ pip install queuerPy
44
23
  ```
45
24
 
46
25
  To use the package you also need a running postgres database with the timescaleDB extension. You can use the `docker-compose.yml` file in the example folder or start a Docker container with the `timescale/timescaledb:latest-pg17` image.
@@ -1,6 +1,6 @@
1
1
  """Version information for queuerPy package."""
2
2
 
3
- __version__ = "0.4.0"
3
+ __version__ = "0.6.0"
4
4
  __version_info__ = tuple(int(part) for part in __version__.split("."))
5
5
 
6
6
  # For compatibility
@@ -6,7 +6,6 @@ Mirrors Go's database/dbJob.go with psycopg3 and references same SQL functions.
6
6
  import json
7
7
  from typing import List, Optional
8
8
  from uuid import UUID
9
- from psycopg import Connection
10
9
  from psycopg.rows import dict_row
11
10
 
12
11
  from helper.database import Database
@@ -24,25 +23,25 @@ class JobDBHandler:
24
23
 
25
24
  def __init__(
26
25
  self,
27
- db_connection: Optional[Database],
26
+ db_connection: Database,
28
27
  with_table_drop: bool = False,
29
28
  encryption_key: str = "",
30
29
  ):
31
30
  """Initialize job database handler."""
32
- if db_connection is None:
33
- raise ValueError("Database connection is None")
34
31
  self.db: Database = db_connection
32
+
35
33
  if self.db.instance is None:
36
34
  raise ValueError("Database connection is not established")
37
35
 
38
36
  self.encryption_key: str = encryption_key
39
37
 
40
- # Load SQL functions using helper.sql
41
- connection: Connection = self.db.instance
42
38
  sql_loader: SQLLoader = SQLLoader()
39
+ sql_loader.load_notify_sql(self.db.instance, force=with_table_drop)
40
+ sql_loader.load_job_sql(self.db.instance, force=with_table_drop)
41
+
42
+ if with_table_drop:
43
+ self.drop_tables()
43
44
 
44
- sql_loader.load_notify_sql(connection, force=with_table_drop)
45
- sql_loader.load_job_sql(connection, force=with_table_drop)
46
45
  self.create_table()
47
46
 
48
47
  def check_tables_existence(self) -> bool:
@@ -84,7 +83,8 @@ class JobDBHandler:
84
83
 
85
84
  def insert_job(self, job: Job) -> Job:
86
85
  """
87
- Insert a job into the database.
86
+ Insert a job into the database using SQL function.
87
+ Note: SQL function only supports basic job creation (no worker assignment, results, or error).
88
88
 
89
89
  :param job: Job instance to insert.
90
90
  :return: Inserted Job instance.
@@ -94,27 +94,7 @@ class JobDBHandler:
94
94
 
95
95
  with self.db.instance.cursor(row_factory=dict_row) as cur:
96
96
  cur.execute(
97
- """
98
- INSERT INTO job (options, task_name, parameters, status, scheduled_at, schedule_count, worker_rid, started_at, results, error)
99
- VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
100
- RETURNING
101
- id,
102
- rid,
103
- worker_id,
104
- worker_rid,
105
- options,
106
- task_name,
107
- parameters,
108
- status,
109
- scheduled_at,
110
- schedule_count,
111
- attempts,
112
- started_at,
113
- results,
114
- error,
115
- created_at,
116
- updated_at;
117
- """,
97
+ "SELECT * FROM insert_job(%s, %s, %s, %s, %s, %s);",
118
98
  (
119
99
  json.dumps(job.options.to_dict()) if job.options else None,
120
100
  job.task_name,
@@ -122,10 +102,6 @@ class JobDBHandler:
122
102
  job.status,
123
103
  job.scheduled_at,
124
104
  job.schedule_count,
125
- job.worker_rid,
126
- job.started_at,
127
- json.dumps(job.results) if job.results else None,
128
- job.error,
129
105
  ),
130
106
  )
131
107
 
@@ -205,26 +181,7 @@ class JobDBHandler:
205
181
  results_param = json.dumps(job.results)
206
182
  if self.encryption_key:
207
183
  cur.execute(
208
- """
209
- SELECT
210
- output_id as id,
211
- output_rid as rid,
212
- output_worker_id as worker_id,
213
- output_worker_rid as worker_rid,
214
- output_options as options,
215
- output_task_name as task_name,
216
- output_parameters as parameters,
217
- output_status as status,
218
- output_scheduled_at as scheduled_at,
219
- output_started_at as started_at,
220
- output_schedule_count as schedule_count,
221
- output_attempts as attempts,
222
- output_results as results,
223
- output_error as error,
224
- output_created_at as created_at,
225
- output_updated_at as updated_at
226
- FROM update_job_final_encrypted(%s, %s, %s, %s, %s);
227
- """,
184
+ "SELECT * FROM update_job_final_encrypted(%s, %s, %s, %s, %s);",
228
185
  (
229
186
  job.id,
230
187
  job.status,
@@ -235,26 +192,7 @@ class JobDBHandler:
235
192
  )
236
193
  else:
237
194
  cur.execute(
238
- """
239
- SELECT
240
- output_id as id,
241
- output_rid as rid,
242
- output_worker_id as worker_id,
243
- output_worker_rid as worker_rid,
244
- output_options as options,
245
- output_task_name as task_name,
246
- output_parameters as parameters,
247
- output_status as status,
248
- output_scheduled_at as scheduled_at,
249
- output_started_at as started_at,
250
- output_schedule_count as schedule_count,
251
- output_attempts as attempts,
252
- output_results as results,
253
- output_error as error,
254
- output_created_at as created_at,
255
- output_updated_at as updated_at
256
- FROM update_job_final(%s, %s, %s, %s);
257
- """,
195
+ "SELECT * FROM update_job_final(%s, %s, %s, %s);",
258
196
  (job.id, job.status, results_param, job.error),
259
197
  )
260
198
 
@@ -288,7 +226,8 @@ class JobDBHandler:
288
226
 
289
227
  def delete_job(self, rid: UUID):
290
228
  """
291
- Delete a job by RID.
229
+ Delete a job by RID using SQL function.
230
+ Mirrors Go's DeleteJob method.
292
231
 
293
232
  :param rid: RID of the job to delete.
294
233
  """
@@ -296,12 +235,13 @@ class JobDBHandler:
296
235
  raise ValueError("Database connection is not established")
297
236
 
298
237
  with self.db.instance.cursor() as cur:
299
- cur.execute("DELETE FROM job WHERE rid = %s;", (rid,))
238
+ cur.execute("SELECT delete_job(%s);", (rid,))
300
239
  self.db.instance.commit()
301
240
 
302
241
  def select_job(self, rid: UUID) -> Optional[Job]:
303
242
  """
304
- Select a job by RID. Mirrors Go's SelectJob method.
243
+ Select a job by RID using SQL function.
244
+ Mirrors Go's SelectJob method.
305
245
 
306
246
  :param rid: RID of the job to select.
307
247
  :return: Job instance if found, else None.
@@ -311,32 +251,7 @@ class JobDBHandler:
311
251
 
312
252
  with self.db.instance.cursor(row_factory=dict_row) as cur:
313
253
  cur.execute(
314
- """
315
- SELECT
316
- id,
317
- rid,
318
- worker_id,
319
- worker_rid,
320
- options,
321
- task_name,
322
- parameters,
323
- status,
324
- scheduled_at,
325
- started_at,
326
- schedule_count,
327
- attempts,
328
- CASE
329
- WHEN octet_length(results_encrypted) > 0 THEN pgp_sym_decrypt(results_encrypted, %s::text)::jsonb
330
- ELSE results
331
- END AS results,
332
- error,
333
- created_at,
334
- updated_at
335
- FROM
336
- job
337
- WHERE
338
- rid = %s;
339
- """,
254
+ "SELECT * FROM select_job(%s, %s);",
340
255
  (self.encryption_key or "", rid),
341
256
  )
342
257
 
@@ -345,7 +260,8 @@ class JobDBHandler:
345
260
 
346
261
  def select_all_jobs(self, last_id: int = 0, entries: int = 100) -> List[Job]:
347
262
  """
348
- Select all jobs with pagination.
263
+ Select all jobs with pagination using SQL function.
264
+ Mirrors Go's SelectAllJobs method.
349
265
 
350
266
  :param last_id: Last job ID from previous page.
351
267
  :param entries: Number of entries to retrieve.
@@ -356,13 +272,8 @@ class JobDBHandler:
356
272
 
357
273
  with self.db.instance.cursor(row_factory=dict_row) as cur:
358
274
  cur.execute(
359
- """
360
- SELECT * FROM job
361
- WHERE id > %s
362
- ORDER BY id
363
- LIMIT %s;
364
- """,
365
- (last_id, entries),
275
+ "SELECT * FROM select_all_jobs(%s, %s, %s);",
276
+ (self.encryption_key or "", last_id, entries),
366
277
  )
367
278
 
368
279
  jobs: List[Job] = []
@@ -375,7 +286,8 @@ class JobDBHandler:
375
286
  self, worker_rid: UUID, last_id: int = 0, entries: int = 100
376
287
  ) -> List[Job]:
377
288
  """
378
- Select all jobs for a specific worker.
289
+ Select all jobs for a specific worker using SQL function.
290
+ Mirrors Go's SelectAllJobsByWorkerRid method.
379
291
 
380
292
  :param worker_rid: RID of the worker.
381
293
  :param last_id: Last job ID from previous page.
@@ -387,13 +299,8 @@ class JobDBHandler:
387
299
 
388
300
  with self.db.instance.cursor(row_factory=dict_row) as cur:
389
301
  cur.execute(
390
- """
391
- SELECT * FROM job
392
- WHERE worker_rid = %s AND id > %s
393
- ORDER BY id
394
- LIMIT %s;
395
- """,
396
- (worker_rid, last_id, entries),
302
+ "SELECT * FROM select_all_jobs_by_worker_rid(%s, %s, %s, %s);",
303
+ (self.encryption_key or "", worker_rid, last_id, entries),
397
304
  )
398
305
 
399
306
  jobs: List[Job] = []
@@ -406,7 +313,8 @@ class JobDBHandler:
406
313
  self, search: str, last_id: int = 0, entries: int = 100
407
314
  ) -> List[Job]:
408
315
  """
409
- Select all jobs filtered by search string. Mirrors Go's SelectAllJobsBySearch method.
316
+ Select all jobs filtered by search string using SQL function.
317
+ Mirrors Go's SelectAllJobsBySearch method.
410
318
  Searches across 'rid', 'worker_id', 'task_name', and 'status' fields.
411
319
 
412
320
  :param search: Search string to filter jobs.
@@ -419,54 +327,8 @@ class JobDBHandler:
419
327
 
420
328
  with self.db.instance.cursor(row_factory=dict_row) as cur:
421
329
  cur.execute(
422
- """
423
- SELECT
424
- id,
425
- rid,
426
- worker_id,
427
- worker_rid,
428
- options,
429
- task_name,
430
- parameters,
431
- status,
432
- scheduled_at,
433
- started_at,
434
- schedule_count,
435
- attempts,
436
- CASE
437
- WHEN octet_length(results_encrypted) > 0 THEN pgp_sym_decrypt(results_encrypted, %s::text)::jsonb
438
- ELSE results
439
- END AS results,
440
- error,
441
- created_at,
442
- updated_at
443
- FROM job
444
- WHERE (rid::text ILIKE '%%' || %s || '%%'
445
- OR worker_id::text ILIKE '%%' || %s || '%%'
446
- OR task_name ILIKE '%%' || %s || '%%'
447
- OR status ILIKE '%%' || %s || '%%')
448
- AND (0 = %s
449
- OR created_at < (
450
- SELECT
451
- u.created_at
452
- FROM
453
- job AS u
454
- WHERE
455
- u.id = %s))
456
- ORDER BY
457
- created_at DESC
458
- LIMIT %s;
459
- """,
460
- (
461
- self.encryption_key or "",
462
- search,
463
- search,
464
- search,
465
- search,
466
- last_id,
467
- last_id,
468
- entries,
469
- ),
330
+ "SELECT * FROM select_all_jobs_by_search(%s, %s, %s, %s);",
331
+ (self.encryption_key or "", search, last_id, entries),
470
332
  )
471
333
 
472
334
  jobs: List[Job] = []
@@ -478,24 +340,33 @@ class JobDBHandler:
478
340
  def add_retention_archive(self, days: int):
479
341
  """
480
342
  Add retention policy for archive cleanup.
481
- Placeholder method - mirrors Go's AddRetentionArchive method.
482
- TODO: Implement archive retention policy.
343
+ Mirrors Go's AddRetentionArchive method.
344
+
345
+ :param days: Number of days to retain archived jobs
483
346
  """
484
- # Placeholder implementation
485
- pass
347
+ if self.db.instance is None:
348
+ raise ValueError("Database connection is not established")
349
+
350
+ with self.db.instance.cursor() as cur:
351
+ cur.execute("SELECT add_retention_archive(%s);", (days,))
352
+ self.db.instance.commit()
486
353
 
487
354
  def remove_retention_archive(self):
488
355
  """
489
356
  Remove retention policy for archive cleanup.
490
- Placeholder method - mirrors Go's RemoveRetentionArchive method.
491
- TODO: Implement archive retention removal.
357
+ Mirrors Go's RemoveRetentionArchive method.
492
358
  """
493
- # Placeholder implementation
494
- pass
359
+ if self.db.instance is None:
360
+ raise ValueError("Database connection is not established")
361
+
362
+ with self.db.instance.cursor() as cur:
363
+ cur.execute("SELECT remove_retention_archive();")
364
+ self.db.instance.commit()
495
365
 
496
366
  def select_job_from_archive(self, rid: UUID) -> Optional[Job]:
497
367
  """
498
- Select a job from archive by RID. Mirrors Go's SelectJobFromArchive method.
368
+ Select a job from archive by RID using SQL function.
369
+ Mirrors Go's SelectJobFromArchive method.
499
370
 
500
371
  :param rid: RID of the job to select.
501
372
  :return: Job instance if found, else None.
@@ -505,32 +376,7 @@ class JobDBHandler:
505
376
 
506
377
  with self.db.instance.cursor(row_factory=dict_row) as cur:
507
378
  cur.execute(
508
- """
509
- SELECT
510
- id,
511
- rid,
512
- worker_id,
513
- worker_rid,
514
- options,
515
- task_name,
516
- parameters,
517
- status,
518
- scheduled_at,
519
- started_at,
520
- schedule_count,
521
- attempts,
522
- CASE
523
- WHEN octet_length(results_encrypted) > 0 THEN pgp_sym_decrypt(results_encrypted, %s::text)::jsonb
524
- ELSE results
525
- END AS results,
526
- error,
527
- created_at,
528
- updated_at
529
- FROM
530
- job_archive
531
- WHERE
532
- rid = %s;
533
- """,
379
+ "SELECT * FROM select_job_from_archive(%s, %s);",
534
380
  (self.encryption_key or "", rid),
535
381
  )
536
382
 
@@ -552,42 +398,8 @@ class JobDBHandler:
552
398
 
553
399
  with self.db.instance.cursor(row_factory=dict_row) as cur:
554
400
  cur.execute(
555
- """
556
- SELECT
557
- id,
558
- rid,
559
- worker_id,
560
- worker_rid,
561
- options,
562
- task_name,
563
- parameters,
564
- status,
565
- scheduled_at,
566
- started_at,
567
- schedule_count,
568
- attempts,
569
- CASE
570
- WHEN octet_length(results_encrypted) > 0 THEN pgp_sym_decrypt(results_encrypted, %s::text)::jsonb
571
- ELSE results
572
- END AS results,
573
- error,
574
- created_at,
575
- updated_at
576
- FROM
577
- job_archive
578
- WHERE (0 = %s
579
- OR created_at < (
580
- SELECT
581
- d.created_at
582
- FROM
583
- job_archive AS d
584
- WHERE
585
- d.id = %s))
586
- ORDER BY
587
- created_at DESC
588
- LIMIT %s;
589
- """,
590
- (self.encryption_key or "", last_id, last_id, entries),
401
+ "SELECT * FROM select_all_jobs_from_archive(%s, %s, %s);",
402
+ (self.encryption_key or "", last_id, entries),
591
403
  )
592
404
 
593
405
  jobs: List[Job] = []
@@ -613,54 +425,8 @@ class JobDBHandler:
613
425
 
614
426
  with self.db.instance.cursor(row_factory=dict_row) as cur:
615
427
  cur.execute(
616
- """
617
- SELECT
618
- id,
619
- rid,
620
- worker_id,
621
- worker_rid,
622
- options,
623
- task_name,
624
- parameters,
625
- status,
626
- scheduled_at,
627
- started_at,
628
- schedule_count,
629
- attempts,
630
- CASE
631
- WHEN octet_length(results_encrypted) > 0 THEN pgp_sym_decrypt(results_encrypted, %s::text)::jsonb
632
- ELSE results
633
- END AS results,
634
- error,
635
- created_at,
636
- updated_at
637
- FROM job_archive
638
- WHERE (rid::text ILIKE '%%' || %s || '%%'
639
- OR worker_id::text ILIKE '%%' || %s || '%%'
640
- OR task_name ILIKE '%%' || %s || '%%'
641
- OR status ILIKE '%%' || %s || '%%')
642
- AND (0 = %s
643
- OR created_at < (
644
- SELECT
645
- d.created_at
646
- FROM
647
- job_archive AS d
648
- WHERE
649
- d.id = %s))
650
- ORDER BY
651
- created_at DESC
652
- LIMIT %s;
653
- """,
654
- (
655
- self.encryption_key or "",
656
- search,
657
- search,
658
- search,
659
- search,
660
- last_id,
661
- last_id,
662
- entries,
663
- ),
428
+ "SELECT * FROM select_all_jobs_from_archive_by_search(%s, %s, %s, %s);",
429
+ (self.encryption_key or "", search, last_id, entries),
664
430
  )
665
431
 
666
432
  jobs: List[Job] = []