Skip to content

Commit 34e5f77

Browse files
committed
added None check
1 parent 817cb87 commit 34e5f77

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

api/src/scripts/populate_db_gtfs.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -292,22 +292,14 @@ 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-
300-
self.logger.info("Refreshing MATERIALIZED FEED SEARCH VIEW - Started")
301-
try:
295+
if t_feedsearch is None:
296+
self.logger.info("Refreshing MATERIALIZED FEED SEARCH VIEW - Started")
302297
session.execute(text(f"REFRESH MATERIALIZED VIEW CONCURRENTLY {t_feedsearch.name}"))
303298
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}")
306-
session.commit()
307-
308-
self.logger.info("\n----- Database populated with sources.csv data. -----")
309-
if trigger_downstream_tasks:
310-
self.trigger_downstream_tasks()
299+
session.commit()
300+
self.logger.info("\n----- Database populated with sources.csv data. -----")
301+
if trigger_downstream_tasks:
302+
self.trigger_downstream_tasks()
311303
except Exception as e:
312304
self.logger.error(f"\n------ Failed to populate the database with sources.csv: {e} -----\n")
313305
exit(1)

0 commit comments

Comments
 (0)