Skip to content

Commit

Permalink
do not send case data in case properties API
Browse files Browse the repository at this point in the history
  • Loading branch information
ajeety4 committed Jun 25, 2024
1 parent 013c59c commit f91eaf5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
4 changes: 0 additions & 4 deletions corehq/apps/data_dictionary/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,10 +552,6 @@ def _get_case_properties_json(cls, case_type_obj, groups_properties_dict=None, s
fhir_enabled=False):
expected_output = {
"name": case_type_obj.name,
"fhir_resource_type": cls.fhir_resource_name if fhir_enabled else None,
"is_deprecated": case_type_obj.is_deprecated,
"module_count": 0,
"is_safe_to_delete": True,
"properties_count": case_type_obj.properties.count(),
"_links": {
"self": f"http://testserver/a/{cls.domain_name}/data_dictionary/json_v2/{case_type_obj.name}/"
Expand Down
20 changes: 4 additions & 16 deletions corehq/apps/data_dictionary/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,28 +184,13 @@ def data_dictionary_json_case_types(request, domain):
@login_and_domain_required
@requires_privilege_with_fallback(privileges.DATA_DICTIONARY)
def data_dictionary_json_case_properties(request, domain, case_type_name):
fhir_resource_type_name_by_case_type = {}
fhir_resource_prop_by_case_prop = {}
if toggles.FHIR_INTEGRATION.enabled(domain):
fhir_resource_type_name_by_case_type = load_fhir_case_type_mapping(domain)
fhir_resource_prop_by_case_prop = load_fhir_case_properties_mapping(domain)

case_type_app_module_count = get_case_type_app_module_count(domain)
used_props_by_case_type = get_used_props_by_case_type(domain)
geo_case_prop = get_geo_case_property(domain)

def _get_case_data(case_type):
module_count = case_type_app_module_count.get(case_type.name, 0)
used_props = used_props_by_case_type.get(case_type.name, [])
return {
"name": case_type.name,
"fhir_resource_type": fhir_resource_type_name_by_case_type.get(case_type),
"is_deprecated": case_type.is_deprecated,
"module_count": module_count,
"is_safe_to_delete": len(used_props) == 0,
"properties_count": case_type.properties_count,
}

try:
skip = int(request.GET.get('skip', 0))
limit = int(request.GET.get('limit', 500))
Expand All @@ -219,7 +204,10 @@ def _get_case_data(case_type):
domain=domain,
name=case_type_name
)
case_type_data = _get_case_data(case_type)
case_type_data = {
"name": case_type.name,
"properties_count": case_type.properties_count,
}

properties_queryset = CaseProperty.objects.select_related('group').filter(case_type=case_type)
properties_queryset = properties_queryset.order_by('group_id', 'index', 'pk')[skip:skip + limit]
Expand Down

0 comments on commit f91eaf5

Please sign in to comment.