Skip to content

Commit

Permalink
OpenConceptLab/ocl_issues#1814 | changelog to reflect concepts with o…
Browse files Browse the repository at this point in the history
…nly mappings changes
  • Loading branch information
snyaggarwal committed Apr 26, 2024
1 parent 9d4fec6 commit 6770968
Showing 1 changed file with 39 additions and 4 deletions.
43 changes: 39 additions & 4 deletions core/common/checksums.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ def get_mapping_summary(self, mapping, mapping_id=None):
'map_type': mapping.map_type,
}

def process(self): # pylint: disable=too-many-locals,too-many-branches
def process(self): # pylint: disable=too-many-locals,too-many-branches,too-many-statements
from core.mappings.models import Mapping
from core.concepts.models import Concept
start_time = time.time()
Expand Down Expand Up @@ -428,7 +428,9 @@ def process(self): # pylint: disable=too-many-locals,too-many-branches
summary['mappings'] = mappings_diff_summary
section_summary[concept_id] = summary
concepts_result[key] = section_summary
for key, diff in self.mappings_diff.result.items():
same_concept_ids = self.concepts_diff.result['same'][self.identity]
smart_same_concept_ids = self.concepts_diff.result['smart_same'][self.identity]
for key, diff in self.mappings_diff.result.items(): # pylint: disable=too-many-nested-blocks
if key in ignored_diffs:
continue
if isinstance(diff, dict):
Expand All @@ -439,8 +441,41 @@ def process(self): # pylint: disable=too-many-locals,too-many-branches
traversed_mappings.add(mapping_id)
mapping_db_id = self.mappings_diff.get_db_id_for(key, mapping_id)
mapping = Mapping.objects.filter(id=mapping_db_id).first()
section_summary[mapping_id] = self.get_mapping_summary(mapping, mapping_id)
mappings_result[key] = section_summary
from_concept_code = get(mapping, 'from_concept_code')
if from_concept_code and from_concept_code not in traversed_concepts:
from_concept = mapping.from_concept
concept_id = from_concept_code
traversed_concepts.add(concept_id)
if concept_id in same_concept_ids:
if 'same_with_mapping_changes' not in concepts_result:
concepts_result['same_with_mapping_changes'] = {}
if concept_id not in concepts_result['same_with_mapping_changes']:
concepts_result['same_with_mapping_changes'][concept_id] = {
'id': concept_id,
'display_name': get(from_concept, 'display_name'),
'mappings': {}
}
if key not in concepts_result['same_with_mapping_changes'][concept_id]['mappings']:
concepts_result['same_with_mapping_changes'][concept_id]['mappings'][key] = []
concepts_result['same_with_mapping_changes'][concept_id]['mappings'][key].append(
self.get_mapping_summary(mapping, mapping_id))
elif concept_id in smart_same_concept_ids:
if 'smart_same_with_mapping_changes' not in concepts_result:
concepts_result['smart_same_with_mapping_changes'] = {}
if concept_id not in concepts_result['smart_same_with_mapping_changes']:
concepts_result['smart_same_with_mapping_changes'][concept_id] = {
'id': concept_id,
'display_name': get(from_concept, 'display_name'),
'mappings': {}
}
if key not in concepts_result['smart_same_with_mapping_changes'][concept_id]['mappings']:
concepts_result['smart_same_with_mapping_changes'][concept_id]['mappings'][key] = []
concepts_result['smart_same_with_mapping_changes'][concept_id]['mappings'][key].append(
self.get_mapping_summary(mapping, mapping_id))
else:
section_summary[mapping_id] = self.get_mapping_summary(mapping, mapping_id)
if section_summary:
mappings_result[key] = section_summary
self.result = {
'concepts': concepts_result,
'mappings': mappings_result,
Expand Down

0 comments on commit 6770968

Please sign in to comment.