Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ addon | version | maintainers | summary
[queue_job_batch](queue_job_batch/) | 18.0.1.0.0 | | Job Queue Batch
[queue_job_cron](queue_job_cron/) | 18.0.1.1.1 | | Scheduled Actions as Queue Jobs
[queue_job_cron_jobrunner](queue_job_cron_jobrunner/) | 18.0.1.0.1 | <a href='https://github.com/ivantodorovich'><img src='https://github.com/ivantodorovich.png' width='32' height='32' style='border-radius:50%;' alt='ivantodorovich'/></a> | Run jobs without a dedicated JobRunner
[queue_job_profiler](queue_job_profiler/) | 18.0.1.0.0 | <a href='https://github.com/simahawk'><img src='https://github.com/simahawk.png' width='32' height='32' style='border-radius:50%;' alt='simahawk'/></a> | Job Queue Profiler
[queue_job_profiler](queue_job_profiler/) | 18.0.1.0.1 | <a href='https://github.com/simahawk'><img src='https://github.com/simahawk.png' width='32' height='32' style='border-radius:50%;' alt='simahawk'/></a> | Job Queue Profiler
[queue_job_subscribe](queue_job_subscribe/) | 18.0.1.0.0 | | Control which users are subscribed to queue job notifications
[test_queue_job](test_queue_job/) | 18.0.2.0.5 | <a href='https://github.com/sbidoul'><img src='https://github.com/sbidoul.png' width='32' height='32' style='border-radius:50%;' alt='sbidoul'/></a> | Queue Job Tests
[test_queue_job_batch](test_queue_job_batch/) | 18.0.1.0.0 | | Test Job Queue Batch
Expand Down
2 changes: 1 addition & 1 deletion queue_job_profiler/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Job Queue Profiler
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:e5e6823382b9de647ff5dda222e6338f224ea4cd51b79b69031930ebe0b35fab
!! source digest: sha256:81110cbf029c5da24b53e16e05ed53c784d8df608158c1506c7464c972af5fbc
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down
2 changes: 1 addition & 1 deletion queue_job_profiler/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{
"name": "Job Queue Profiler",
"version": "18.0.1.0.0",
"version": "18.0.1.0.1",
"author": "Camptocamp, Odoo Community Association (OCA)",
"maintainers": ["simahawk"],
"website": "https://github.com/OCA/queue",
Expand Down
18 changes: 11 additions & 7 deletions queue_job_profiler/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,28 @@


class RunJobController(BaseController):
def _try_perform_job(self, env, job):
if self._profiler_is_enabled(env, job):
return self._profiler_perform_job(env, job)
@classmethod
def _try_perform_job(cls, env, job):
if cls._profiler_is_enabled(env, job):
return cls._profiler_perform_job(env, job)
return super()._try_perform_job(env, job)

def _profiler_is_enabled(self, env, job):
@classmethod
def _profiler_is_enabled(cls, env, job):
func_id = job.job_config.job_function_id
if not func_id:
return False
job_function = env["queue.job.function"].browse(func_id)
return job_function.is_profiling_enabled()

def _profiler_perform_job(self, env, job):
with self._profiler_get(env, job):
@classmethod
def _profiler_perform_job(cls, env, job):
with cls._profiler_get(env, job):
result = super()._try_perform_job(env, job)
return result

def _profiler_get(self, env, job):
@classmethod
def _profiler_get(cls, env, job):
func_id = job.job_config.job_function_id
if not func_id:
return None
Expand Down
2 changes: 1 addition & 1 deletion queue_job_profiler/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ <h1>Job Queue Profiler</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:e5e6823382b9de647ff5dda222e6338f224ea4cd51b79b69031930ebe0b35fab
!! source digest: sha256:81110cbf029c5da24b53e16e05ed53c784d8df608158c1506c7464c972af5fbc
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/queue/tree/18.0/queue_job_profiler"><img alt="OCA/queue" src="https://img.shields.io/badge/github-OCA%2Fqueue-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/queue-18-0/queue-18-0-queue_job_profiler"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/queue&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This addon adds profiling controls to queue job functions and wraps
Expand Down
6 changes: 1 addition & 5 deletions queue_job_profiler/tests/test_job_profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,8 @@ def test_job_action_view_profile(self):
self.assertEqual(action["res_id"], prof.id)

def _run_controller(self, job, user=None):
controller = RunJobController()
env = self.env(user=user) if user else self.env
with (
patch.object(self.env.cr, "commit"),
):
controller._try_perform_job(env, job)
RunJobController._try_perform_job(env, job)

def test_controller(self):
job = self.env.user.with_delay().read(["id"])
Expand Down
Loading