Skip to content

Commit

Permalink
fix bug where during the csv generation the database would raise a va…
Browse files Browse the repository at this point in the history
…lue error for properly configured internal 'PartOf' links
  • Loading branch information
northdpole committed Nov 12, 2024
1 parent c4748eb commit c68969d
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions application/database/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -1177,9 +1177,8 @@ def __make_cre_internal_links(self, cre: CRE) -> List[cre_defs.Link]:
linked_cre_query = self.session.query(CRE)
link_type = cre_defs.LinkTypes.from_str(internal_link.type)

if (
internal_link.cre == cre.id
): # if we are the lower cre in this relationship, we need to flip the "Contains" linktypes
if internal_link.cre == cre.id:
# if we are the lower cre in this relationship, we need to flip the "Contains" linktypes
linked_cre = linked_cre_query.filter(
CRE.id == internal_link.group
).first() # get the higher cre so we can add the link
Expand All @@ -1196,17 +1195,14 @@ def __make_cre_internal_links(self, cre: CRE) -> List[cre_defs.Link]:
links.append(
cre_defs.Link(ltype=link_type, document=CREfromDB(linked_cre))
)
else:
raise ValueError(
f"Received an unexpected link type {link_type} in internal link between {linked_cre.name} and {cre.name}"
)
else: # if we are are the higher cre then we don't need to do anything, relationship types are always "higher"->"lower"
linked_cre = linked_cre_query.filter(
CRE.id == internal_link.cre
).first()
links.append(
cre_defs.Link(ltype=link_type, document=CREfromDB(linked_cre))
)

# if we are are the higher cre then we don't need to do anything, relationship types are always "higher"->"lower"
linked_cre = linked_cre_query.filter(
CRE.id == internal_link.cre
).first()
links.append(
cre_defs.Link(ltype=link_type, document=CREfromDB(linked_cre))
)
return links

def __make_cre_links(
Expand Down

0 comments on commit c68969d

Please sign in to comment.