-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
refactor: AssignmentRule.apply #26371
base: develop
Are you sure you want to change the base?
Conversation
Enqueue notifications in bulk rather than individually.
- Add typing hints to APIs - Pass doc as kwarg in assign_to.add to bypass re-fetching - Remove redundant code blocks (add_column _assign, extra error handling) - Use caches whenever available, and less expensive condition eval order
4f84882
to
97a6b12
Compare
888e858
to
be54e6f
Compare
@@ -292,6 +292,7 @@ def init(site: str, sites_path: str = ".", new_site: bool = False, force=False) | |||
local.role_permissions = {} | |||
local.valid_columns = {} | |||
local.new_doc_templates = {} | |||
local.system_notifications_queue = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't this just be part of enqueue to flush after commit?
It implements same exact behavior:
- Queue till commit
- flush after commit
- clear queue in case of rollback or no commit
make_notification_log(doc, users) | ||
else: | ||
frappe.local.system_notifications_queue.append((doc, users)) | ||
if flush_system_notifications not in frappe.db.after_commit._functions: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if flush_system_notifications not in frappe.db.after_commit._functions: | |
if not frappe.local.system_notifications_queue: |
Can do this instead of relying on internal attribute. Line will have to move up before append
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pattern is very common though, maybe we should have deduplicate
or once
flag on callback manager 😄
Changes
_assign
in tables