Skip to content

Commit

Permalink
Merge pull request hifis-net#49 from Normo/release-foreign-key-constr…
Browse files Browse the repository at this point in the history
…aint

Fix removal of release content
  • Loading branch information
Normo authored Nov 30, 2023
2 parents 8df29ce + f960990 commit 1a156df
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ async def remove_spotlight(client, spotlight):
name = spotlight.get("name")
slug = name_to_slug(name)
software_id = await slug_to_id(client, slug)
logging.info("Removing %s", name)

if software_id is not None:
# remove related entries
Expand All @@ -242,21 +243,18 @@ async def remove_spotlight(client, spotlight):
.execute()
)

try:
res = (
await client.from_("release")
.select("id")
.eq("software", software_id)
.execute()
)
except APIError as exc:
logging.info("Catch exception: %s", exc)
res = (
await client.from_("release")
.select("software")
.eq("software", software_id)
.execute()
)

for rel in res.data:
res = (
await client.from_("release_content")
await client.from_("release_version")
.delete()
.eq("release_id", rel.get("id"))
.eq("release_id", rel.get("software"))
.execute()
)

Expand Down

0 comments on commit 1a156df

Please sign in to comment.