Skip to content

Commit

Permalink
addition of code to filter out nowcast runs
Browse files Browse the repository at this point in the history
  • Loading branch information
PhillipsOwen committed Jun 27, 2023
1 parent 5f6a7bf commit c0b2b76
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/common/pg_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,14 @@ def __del__(self):
# clean up connections and cursors
PGUtilsMultiConnect.__del__(self)

def get_catalog_member_records(self, run_id: str = None, project_code: str = None, limit: int = None) -> dict:
def get_catalog_member_records(self, run_id: str = None, project_code: str = None, filter_event_type: str = None, limit: int = None) -> dict:
"""
gets the apsviz catalog member record for the run id passed. the SP default
record count returned can be overridden.
:param run_id:
:param project_code:
:param filter_event_type:
:param limit:
:return:
"""
Expand All @@ -74,14 +75,20 @@ def get_catalog_member_records(self, run_id: str = None, project_code: str = Non
else:
project_code = ', _project_code := NULL'

# did we get a filter event type
if filter_event_type is not None:
filter_event_type = f", _filter_event_type := '{filter_event_type}'"
else:
filter_event_type = ', _filter_event_type := NULL'

# did we get a limit
if limit is not None:
limit = f', _limit := {limit}'
else:
limit = ', _limit := NULL'

# create the sql. note we are appending a '%' wildcard to get all products for this run
sql: str = f"SELECT public.get_catalog_member_records({run_id}{project_code}{limit});"
sql: str = f"SELECT public.get_catalog_member_records({run_id}{project_code}{filter_event_type}{limit});"

# get the layer list
ret_val = self.exec_sql('apsviz', sql)
Expand Down
2 changes: 1 addition & 1 deletion src/sync/psc_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def run(self, run_id: str, physical_location: str) -> bool:
if physical_location.startswith(self.psc_physical_location):
try:
# make the DB request to get the catalogs
catalog_data: dict = self.db_info.get_catalog_member_records(run_id)
catalog_data: dict = self.db_info.get_catalog_member_records(run_id=run_id, filter_event_type='nowcast')

# if we got data push it to PSC
if catalog_data is not None and catalog_data['catalogs'] is not None:
Expand Down

0 comments on commit c0b2b76

Please sign in to comment.