perf: Task import with Project (#17496)
When tasks are imported with their Project set, import slows down as number of tasks increase. This is largely due to `load_tasks` being called in Project which is only required when Form loads. So, we can skip it during import. Also, converted some get_doc calls to get_cached_doc.
This commit is contained in:
parent
a90fe810b3
commit
23fecc0dbb
@ -35,6 +35,9 @@ class Project(Document):
|
|||||||
|
|
||||||
def load_tasks(self):
|
def load_tasks(self):
|
||||||
"""Load `tasks` from the database"""
|
"""Load `tasks` from the database"""
|
||||||
|
if frappe.flags.in_import:
|
||||||
|
return
|
||||||
|
|
||||||
self.tasks = []
|
self.tasks = []
|
||||||
for task in self.get_tasks():
|
for task in self.get_tasks():
|
||||||
task_map = {
|
task_map = {
|
||||||
|
@ -105,7 +105,7 @@ class Task(NestedSet):
|
|||||||
|
|
||||||
def update_project(self):
|
def update_project(self):
|
||||||
if self.project and not self.flags.from_project:
|
if self.project and not self.flags.from_project:
|
||||||
frappe.get_doc("Project", self.project).update_project()
|
frappe.get_cached_doc("Project", self.project).update_project()
|
||||||
|
|
||||||
def check_recursion(self):
|
def check_recursion(self):
|
||||||
if self.flags.ignore_recursion_check: return
|
if self.flags.ignore_recursion_check: return
|
||||||
@ -150,7 +150,7 @@ class Task(NestedSet):
|
|||||||
|
|
||||||
def populate_depends_on(self):
|
def populate_depends_on(self):
|
||||||
if self.parent_task:
|
if self.parent_task:
|
||||||
parent = frappe.get_doc('Task', self.parent_task)
|
parent = frappe.get_cached_doc('Task', self.parent_task)
|
||||||
if not self.name in [row.task for row in parent.depends_on]:
|
if not self.name in [row.task for row in parent.depends_on]:
|
||||||
parent.append("depends_on", {
|
parent.append("depends_on", {
|
||||||
"doctype": "Task Depends On",
|
"doctype": "Task Depends On",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user