diff --git a/daily_read/ngi_data.py b/daily_read/ngi_data.py index 1a78feb..20a6e49 100644 --- a/daily_read/ngi_data.py +++ b/daily_read/ngi_data.py @@ -358,6 +358,10 @@ def get_data(self, project_id=None, close_date=None): if close_date is None: close_date = (datetime.datetime.now() - relativedelta(months=6)).strftime("%Y-%m-%d") for row in self.statusdb_session.rows(close_date=close_date): + if "portal_id" not in row.value: + # Probably a project with no associated order(e.g legacy ESCG), log it and skip + log.error(f"No portal_id found in row {row.id}, skipping it!") + continue portal_id = row.value["portal_id"] order_year = row.value["order_year"] # Should not happen, upstream manual entry error if it happens