From 24ac05900b4aab8924300d62b0fc40e051e81755 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Sat, 29 Jan 2022 20:47:56 +0100 Subject: [PATCH 1/6] Improve mock_jobs documentation --- queue_job/readme/USAGE.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/queue_job/readme/USAGE.rst b/queue_job/readme/USAGE.rst index 743da10236..8f7da0473c 100644 --- a/queue_job/readme/USAGE.rst +++ b/queue_job/readme/USAGE.rst @@ -318,6 +318,12 @@ tests), and it makes tests smaller. The best way to run such assertions on the enqueued jobs is to use ``odoo.addons.queue_job.tests.common.trap_jobs()``. +Inside this context manager, instead of being added in the database's queue, +jobs are pushed in an in-memory list. The context manager then provides useful +helpers to verify that jobs have been enqueued with the expected arguments. It +even can run the jobs of its list synchronously! Details in +``odoo.addons.queue_job.tests.common.JobsTester``. + A very small example (more details in ``tests/common.py``): .. code-block:: python From 9a72a52b253a34df97f99b0870a0b4eff16742e6 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Sat, 29 Jan 2022 21:52:00 +0100 Subject: [PATCH 2/6] Add docstring for create_test_job controller --- queue_job/controllers/main.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/queue_job/controllers/main.py b/queue_job/controllers/main.py index da42b53e99..f83aa9b54f 100644 --- a/queue_job/controllers/main.py +++ b/queue_job/controllers/main.py @@ -175,6 +175,16 @@ def create_test_job( size=1, failure_rate=0, ): + """Create test jobs + + Examples of urls: + + * http://127.0.0.1:8069/queue_job/create_test_job: single job + * http://127.0.0.1:8069/queue_job/create_test_job?size=10: a graph of 10 jobs + * http://127.0.0.1:8069/queue_job/create_test_job?size=10&failure_rate=0.5: + a graph of 10 jobs, half will fail + + """ if not http.request.env.user.has_group("base.group_erp_manager"): raise Forbidden(_("Access Denied")) From e721b434a63660d834e21e8c1fb4f0ae0d1dc713 Mon Sep 17 00:00:00 2001 From: hparfr Date: Tue, 3 Jan 2023 09:58:22 +0100 Subject: [PATCH 3/6] IMP queue_job: add cancelled filter --- queue_job/views/queue_job_views.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/queue_job/views/queue_job_views.xml b/queue_job/views/queue_job_views.xml index d58739a82e..51336f5197 100644 --- a/queue_job/views/queue_job_views.xml +++ b/queue_job/views/queue_job_views.xml @@ -244,6 +244,11 @@ string="Failed" domain="[('state', '=', 'failed')]" /> + Date: Mon, 27 Nov 2023 10:35:47 +0100 Subject: [PATCH 4/6] queue_job: split identity_key hasher to ease reuse You can now create your own identity exact matcher using the default hasher as a base. --- queue_job/job.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/queue_job/job.py b/queue_job/job.py index 1a61881e30..d38a899095 100644 --- a/queue_job/job.py +++ b/queue_job/job.py @@ -89,14 +89,19 @@ def identity_example(job_): Usually you will probably always want to include at least the name of the model and method. """ + hasher = identity_exact_hasher(job_) + return hasher.hexdigest() + + +def identity_exact_hasher(job_): + """Prepare hasher object for identity_exact.""" hasher = hashlib.sha1() hasher.update(job_.model_name.encode("utf-8")) hasher.update(job_.method_name.encode("utf-8")) hasher.update(str(sorted(job_.recordset.ids)).encode("utf-8")) hasher.update(str(job_.args).encode("utf-8")) hasher.update(str(sorted(job_.kwargs.items())).encode("utf-8")) - - return hasher.hexdigest() + return hasher @total_ordering From 1084068616a69000cf03ce640f9ca3acb7bd841f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Alix?= Date: Wed, 6 Mar 2024 12:03:03 +0100 Subject: [PATCH 5/6] queue_job: fix partial index to add 'wait_dependencies' state --- queue_job/__manifest__.py | 2 +- queue_job/migrations/15.0.2.3.6/pre-migration.py | 10 ++++++++++ queue_job/models/queue_job.py | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 queue_job/migrations/15.0.2.3.6/pre-migration.py diff --git a/queue_job/__manifest__.py b/queue_job/__manifest__.py index 97cc820956..8fea895a4c 100644 --- a/queue_job/__manifest__.py +++ b/queue_job/__manifest__.py @@ -2,7 +2,7 @@ { "name": "Job Queue", - "version": "15.0.2.3.5", + "version": "15.0.2.3.6", "author": "Camptocamp,ACSONE SA/NV,Odoo Community Association (OCA)", "website": "https://github.com/OCA/queue", "license": "LGPL-3", diff --git a/queue_job/migrations/15.0.2.3.6/pre-migration.py b/queue_job/migrations/15.0.2.3.6/pre-migration.py new file mode 100644 index 0000000000..53d9690caa --- /dev/null +++ b/queue_job/migrations/15.0.2.3.6/pre-migration.py @@ -0,0 +1,10 @@ +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html) + +from odoo.tools.sql import table_exists + + +def migrate(cr, version): + if table_exists(cr, "queue_job"): + # Drop index 'queue_job_identity_key_state_partial_index', + # it will be recreated during the update + cr.execute("DROP INDEX IF EXISTS queue_job_identity_key_state_partial_index;") diff --git a/queue_job/models/queue_job.py b/queue_job/models/queue_job.py index 7eb1620cfb..0f0b866273 100644 --- a/queue_job/models/queue_job.py +++ b/queue_job/models/queue_job.py @@ -139,7 +139,7 @@ def init(self): self._cr.execute( "CREATE INDEX queue_job_identity_key_state_partial_index " "ON queue_job (identity_key) WHERE state in ('pending', " - "'enqueued') AND identity_key IS NOT NULL;" + "'enqueued', 'wait_dependencies') AND identity_key IS NOT NULL;" ) @api.depends("records") From 5d0a00a354b92086e52c99b54ecf43746490177d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Alix?= Date: Wed, 6 Mar 2024 13:48:35 +0100 Subject: [PATCH 6/6] oca-port: update blacklist --- .oca/oca-port/blacklist/queue_job.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.oca/oca-port/blacklist/queue_job.json b/.oca/oca-port/blacklist/queue_job.json index 2cf4dd06eb..a208b8dcc4 100644 --- a/.oca/oca-port/blacklist/queue_job.json +++ b/.oca/oca-port/blacklist/queue_job.json @@ -6,6 +6,9 @@ "466": "Reverts https://github.com/OCA/queue/pull/387", "511": "Icon already updated for v15", "443": "Squashed w/ 453, commit rewritten", - "453": "Squashed w/ 443, commit rewritten" + "453": "Squashed w/ 443, commit rewritten", + "403": "Lint fixes, relevant code already ported", + "537": "Already ported", + "571": "Already ported" } }