Skip to content

Commit

Permalink
add optimizations on detail
Browse files Browse the repository at this point in the history
  • Loading branch information
mkangia committed Feb 19, 2025
1 parent 2ed521a commit 7ae835d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions corehq/apps/app_manager/suite_xml/sections/details.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ def get_section_elements(self):
)
if d:
elements.append(d)
if self.app.supports_case_list_optimizations:
_add_detail_optimizations(module_detail=detail, detail_xml_object=d)

# add the persist case context if needed and if
# case tiles are present and have their own persistent block
Expand Down Expand Up @@ -592,6 +594,21 @@ def get_detail_id_safe(self, module, detail_type):
return detail_id if detail_id in self.active_details else None


def _add_detail_optimizations(module_detail, detail_xml_object):
column_optimizations = [
column.optimization if column.supports_optimizations else None
for column in module_detail.get_columns()
]
if 'cache_and_lazy_load' in column_optimizations:
detail_xml_object.cache_enabled = True
detail_xml_object.lazy_loading = True
else:
if 'cache' in column_optimizations:
detail_xml_object.cache_enabled = True
if 'lazy_load' in column_optimizations:
detail_xml_object.lazy_loading = True


def get_nodeset_sort_elements(detail):
from corehq.apps.app_manager.models import SortElement
sort_elements = defaultdict(list)
Expand Down
1 change: 1 addition & 0 deletions corehq/apps/app_manager/suite_xml/xml_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,7 @@ class Detail(OrderedXmlObject, IdNode):
ROOT_NAME = 'detail'

lazy_loading = BooleanField('@lazy_loading')
cache_enabled = BooleanField('@cache_enabled', required=False)

ORDER = ('title', 'lookup', 'no_items_text', 'details', 'fields')

Expand Down

0 comments on commit 7ae835d

Please sign in to comment.