Skip to content

Commit 817cb87

Browse files
committed
fixed 'NoneType' object has no attribute 'name'
1 parent 7256a6e commit 817cb87

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

api/src/scripts/populate_db_gtfs.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,19 @@ def initialize(self, trigger_downstream_tasks: bool = True):
292292
self.populate_db(session)
293293
session.commit()
294294

295+
# Check if t_feedsearch is properly initialized
296+
if t_feedsearch is None or not hasattr(t_feedsearch, "name"):
297+
self.logger.error("t_feedsearch is not initialized or does not have a 'name' attribute.")
298+
raise ValueError("t_feedsearch is not properly initialized.")
299+
295300
self.logger.info("Refreshing MATERIALIZED FEED SEARCH VIEW - Started")
296-
session.execute(text(f"REFRESH MATERIALIZED VIEW CONCURRENTLY {t_feedsearch.name}"))
297-
self.logger.info("Refreshing MATERIALIZED FEED SEARCH VIEW - Completed")
301+
try:
302+
session.execute(text(f"REFRESH MATERIALIZED VIEW CONCURRENTLY {t_feedsearch.name}"))
303+
self.logger.info("Refreshing MATERIALIZED FEED SEARCH VIEW - Completed")
304+
except Exception as e:
305+
self.logger.error(f"Failed to refresh materialized view: {e}")
298306
session.commit()
307+
299308
self.logger.info("\n----- Database populated with sources.csv data. -----")
300309
if trigger_downstream_tasks:
301310
self.trigger_downstream_tasks()

0 commit comments

Comments
 (0)