Skip to content

Commit

Permalink
Molnix data structure change
Browse files Browse the repository at this point in the history
  • Loading branch information
szabozoltan69 committed Jan 16, 2025
1 parent 3af3eba commit e38f86e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions api/management/commands/sync_molnix.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@ def sync_deployments(molnix_deployments, molnix_api, countries):

# Create Personnel objects
for md in molnix_deployments:
if "position_id" not in md: # changed structure §
md2 = molnix_api.get_deployment(md["id"])
md |= md2["deployment"]
if skip_this(md["tags"]):
warning = "Deployment id %d skipped due to No-GO" % md["id"]
logger.warning(warning)
Expand Down Expand Up @@ -322,6 +325,7 @@ def sync_deployments(molnix_deployments, molnix_api, countries):

surge_alert = None
try:
# Should not happen after the "changed structure §" fix:
if "position_id" not in md:
warning = "%d deployment did not find SurgeAlert in lack of Molnix position_id" % md["id"]
logger.warning(warning)
Expand Down
6 changes: 6 additions & 0 deletions api/molnix_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ def get_position(self, id):
except Exception:
return None

def get_deployment(self, id):
try:
return self.call_api(path="deployments/%d" % id)
except Exception:
return None

def get_countries(self):
countries = self.call_api(path="countries")
countries_list = countries["countries"]
Expand Down

0 comments on commit e38f86e

Please sign in to comment.