refactor: change existing functionality in framework to check if get_docs is working
This commit is contained in:
parent
16efc5fa45
commit
c174881534
5 changed files with 10 additions and 16 deletions
|
|
@ -617,18 +617,16 @@ class User(Document):
|
|||
frappe.db.delete("List Filter", {"for_user": self.name})
|
||||
|
||||
# Remove user from Note's Seen By table
|
||||
seen_notes = frappe.get_all("Note", filters=[["Note Seen By", "user", "=", self.name]], pluck="name")
|
||||
for note_id in seen_notes:
|
||||
note = frappe.get_doc("Note", note_id)
|
||||
seen_notes = frappe.get_docs("Note", filters=[["Note Seen By", "user", "=", self.name]])
|
||||
for note in seen_notes:
|
||||
for row in note.seen_by:
|
||||
if row.user == self.name:
|
||||
note.remove(row)
|
||||
note.save(ignore_permissions=True)
|
||||
|
||||
# Unlink user from all of its invitation docs
|
||||
invites = frappe.db.get_all("User Invitation", filters={"email": self.name}, pluck="name")
|
||||
for invite in invites:
|
||||
invite_doc = frappe.get_doc("User Invitation", invite)
|
||||
invites = frappe.get_docs("User Invitation", filters={"email": self.name})
|
||||
for invite_doc in invites:
|
||||
invite_doc.user = None
|
||||
invite_doc.save(ignore_permissions=True)
|
||||
|
||||
|
|
|
|||
|
|
@ -206,12 +206,11 @@ class UserInvitation(Document):
|
|||
|
||||
def mark_expired_invitations() -> None:
|
||||
days = 3
|
||||
invitations_to_expire = frappe.db.get_all(
|
||||
invitations_to_expire = frappe.get_docs(
|
||||
"User Invitation",
|
||||
filters={"status": "Pending", "creation": ["<", frappe.utils.add_days(frappe.utils.now(), -days)]},
|
||||
)
|
||||
for invitation in invitations_to_expire:
|
||||
invitation = frappe.get_doc("User Invitation", invitation.name)
|
||||
invitation.expire()
|
||||
# to avoid losing work in case the job times out without finishing
|
||||
frappe.db.commit() # nosemgrep
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ class Event(Document):
|
|||
return
|
||||
|
||||
for participant in self.event_participants:
|
||||
if communications := frappe.get_all(
|
||||
if communications := frappe.get_docs(
|
||||
"Communication",
|
||||
filters=[
|
||||
["Communication", "reference_doctype", "=", self.doctype],
|
||||
|
|
@ -145,11 +145,9 @@ class Event(Document):
|
|||
["Communication Link", "link_doctype", "=", participant.reference_doctype],
|
||||
["Communication Link", "link_name", "=", participant.reference_docname],
|
||||
],
|
||||
pluck="name",
|
||||
distinct=True,
|
||||
):
|
||||
for comm in communications:
|
||||
communication = frappe.get_doc("Communication", comm)
|
||||
for communication in communications:
|
||||
self.update_communication(participant, communication)
|
||||
else:
|
||||
meta = frappe.get_meta(participant.reference_doctype)
|
||||
|
|
|
|||
|
|
@ -359,8 +359,8 @@ def process_auto_email_report(report):
|
|||
|
||||
def send_monthly():
|
||||
"""Check reports to be sent monthly"""
|
||||
for report in frappe.get_all("Auto Email Report", {"enabled": 1, "frequency": "Monthly"}):
|
||||
frappe.get_doc("Auto Email Report", report.name).send()
|
||||
for report in frappe.get_docs("Auto Email Report", filters={"enabled": 1, "frequency": "Monthly"}):
|
||||
report.send()
|
||||
|
||||
|
||||
def make_links(columns, data):
|
||||
|
|
|
|||
|
|
@ -132,10 +132,9 @@ def enqueue_events_for_site(site: str) -> None:
|
|||
def enqueue_events() -> list[str] | None:
|
||||
if schedule_jobs_based_on_activity():
|
||||
enqueued_jobs = []
|
||||
all_jobs = frappe.get_all("Scheduled Job Type", filters={"stopped": 0}, fields="*")
|
||||
all_jobs = frappe.get_docs("Scheduled Job Type", filters={"stopped": 0})
|
||||
random.shuffle(all_jobs)
|
||||
for job_type in all_jobs:
|
||||
job_type = frappe.get_doc(doctype="Scheduled Job Type", **job_type)
|
||||
try:
|
||||
if job_type.enqueue():
|
||||
enqueued_jobs.append(job_type.method)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue