Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMP] queue_job: Add split method #658

Merged
merged 1 commit into from
Nov 19, 2024

Conversation

paradoxxxzero
Copy link
Contributor

@paradoxxxzero paradoxxxzero commented Jun 4, 2024

This is a draft PR trying an alternative approach for #566

  class ResPartner(models.Model):
      # ...

      def copy_all_partners(self):
          # Duplicate all partners in batches of 30:
          self.with_delay(split=30).copy()

    # or

     def copy_all_partners(self):
          # Duplicate all partners in batches of 30:
          self.delayable().set(description='Copy Partners').copy().split(30).delay()

  # ...
  self.env['res.partner'].search([], limit=1000).copy_all_partners()

The split function on Delayable returns a DelayableGroup.

This is an attempt and I am open to suggestions

@OCA-git-bot
Copy link
Contributor

Hi @guewen,
some modules you are maintaining are being modified, check this out!

@paradoxxxzero paradoxxxzero force-pushed the 14.0-imp-queue_job-split branch from f1e4b8b to 6131cf1 Compare June 4, 2024 08:35
queue_job/delay.py Outdated Show resolved Hide resolved
queue_job/delay.py Outdated Show resolved Hide resolved
queue_job/delay.py Outdated Show resolved Hide resolved
@paradoxxxzero paradoxxxzero force-pushed the 14.0-imp-queue_job-split branch from 6131cf1 to feab369 Compare June 4, 2024 14:27
Copy link
Contributor

@amh-mw amh-mw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@paradoxxxzero paradoxxxzero marked this pull request as ready for review June 4, 2024 14:32
@paradoxxxzero
Copy link
Contributor Author

The coverage does not seem to include the unittest :/

@amh-mw
Copy link
Contributor

amh-mw commented Jun 4, 2024

The coverage does not seem to include the unittest :/

Import the new test in tests/__init__.py

@paradoxxxzero paradoxxxzero force-pushed the 14.0-imp-queue_job-split branch 2 times, most recently from facdc08 to 46f344e Compare June 4, 2024 15:12
@paradoxxxzero
Copy link
Contributor Author

paradoxxxzero commented Jun 4, 2024

They weren't run as they were unitest.TestCase, I changed them to TransactionCase for odoo to run them.

@paradoxxxzero paradoxxxzero force-pushed the 14.0-imp-queue_job-split branch from 46f344e to 3865f14 Compare July 2, 2024 10:42
@paradoxxxzero
Copy link
Contributor Author

I added a chain parameter to split into a chain instead of a group.

Is there anything lacking for this to be merged?

@amh-mw
Copy link
Contributor

amh-mw commented Jul 2, 2024

Is there anything lacking for this to be merged?

Just the attention of @OCA/connector-maintainers

@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

1 similar comment
@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

Copy link
Contributor

@simahawk simahawk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks! Just some minor remarks :)

@guewen ping :)

queue_job/tests/test_delayable.py Outdated Show resolved Hide resolved
queue_job/tests/test_delayable_split.py Outdated Show resolved Hide resolved
queue_job/delay.py Outdated Show resolved Hide resolved
Copy link

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Nov 17, 2024
@paradoxxxzero paradoxxxzero force-pushed the 14.0-imp-queue_job-split branch from 3865f14 to 53558ed Compare November 18, 2024 08:06
@simahawk simahawk removed the stale PR/Issue without recent activity, it'll be soon closed automatically. label Nov 18, 2024
@simahawk
Copy link
Contributor

As this is not touching any existing feature and is not adding a lot of code IMO we can move on w/ the merge.
Yet, I think we miss a bit of documentation. Can you add something to the README pls?

@paradoxxxzero paradoxxxzero force-pushed the 14.0-imp-queue_job-split branch from 53558ed to f929b64 Compare November 19, 2024 08:21
@paradoxxxzero
Copy link
Contributor Author

Done

@simahawk
Copy link
Contributor

/ocabot merge minor

@OCA-git-bot
Copy link
Contributor

On my way to merge this fine PR!
Prepared branch 14.0-ocabot-merge-pr-658-by-simahawk-bump-minor, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 6584cbc into OCA:14.0 Nov 19, 2024
7 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at cf2ff24. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants