Skip to content

Commit

Permalink
feat(mapper): force add tags if not provided but mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
yshalenyk committed Jun 19, 2024
1 parent e3e814c commit b5aa619
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions nightingale/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def transform_data(self, data: list[dict[Any, Any]], mapping: Mapping) -> list[d
self.tag_initiation_type(curr_release)
self.date_release(curr_release)
self.tag_ocid(curr_release, curr_ocid)
self.tag_tags(curr_release)
self.make_release_id(curr_release)
logger.info(f"Release mapped: {curr_release['ocid']}")
mapped.append(curr_release)
Expand Down Expand Up @@ -131,6 +132,7 @@ def set_nested_value(nested_dict, keys, value, schema, add_new=False):
if last_key not in nested_dict[-1]:
nested_dict[-1][last_key] = []
nested_dict[-1][last_key].append(value)

else:
if not nested_dict:
nested_dict.append({})
Expand Down Expand Up @@ -237,3 +239,13 @@ def tag_ocid(self, curr_row: dict, curr_ocid: str) -> None:
:type curr_ocid: str
"""
curr_row["ocid"] = self.produce_ocid(curr_ocid)

def tag_tags(self, curr_row) -> None:
if "tag" not in curr_row:
curr_row["tag"] = []
if "tender" in curr_row:
curr_row["tag"].append("tender")
if "award" in curr_row:
curr_row["tag"].append("award")
if "contract" in curr_row:
curr_row["tag"].append("contract")

0 comments on commit b5aa619

Please sign in to comment.