Skip to content

Commit 3cfb4f4

Browse files
committed
-> ETL comment
1 parent 010ae4e commit 3cfb4f4

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

etl/etl.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -681,11 +681,16 @@ def update_display_values(attr, updates):
681681
logger.info("[STATUS] Added {} display values.".format(str(len(new_vals))))
682682

683683

684-
def load_tooltips(source_objs, attr_name, source_tooltip, obj_attr=None):
684+
def load_tooltips(source_objs, attr_name, source_tooltip, obj_id_col=None):
685685
try:
686686
attr = Attribute.objects.get(name=attr_name, active=True)
687-
if not obj_attr:
688-
obj_attr = attr_name
687+
# In some cases, the data sourcing the tooltip does not have an ID column with a name which matches
688+
# the attribute name (eg. in Collections, analysis results and collections both have a collection_id,
689+
# but in Attributes, analysis_result_id and collection_id are distinct attributes).
690+
# Used obi_id_col to specify the column in which the ID of the value to associate with the tooltip source in
691+
# the case the attribute name is different from the source object's column ID
692+
if not obj_id_col:
693+
obj_id_col = attr_name
689694

690695
tips = Attribute_Tooltips.objects.select_related('attribute').filter(attribute=attr)
691696

@@ -696,7 +701,7 @@ def load_tooltips(source_objs, attr_name, source_tooltip, obj_attr=None):
696701
extent_tooltips[tip.attribute.id] = []
697702
extent_tooltips[tip.attribute.id].append(tip.tooltip_id)
698703

699-
tooltips_by_val = {x[obj_attr]: {'tip': x[source_tooltip]} for x in source_objs.values() if x[obj_attr] != '' and x[obj_attr] is not None}
704+
tooltips_by_val = {x[obj_id_col]: {'tip': x[source_tooltip]} for x in source_objs.values() if x[obj_id_col] != '' and x[obj_id_col] is not None}
700705

701706
new_tooltips = []
702707
updated_tooltips = []

0 commit comments

Comments
 (0)