Skip to content

Commit

Permalink
updated reftime retrieval from admin.ingest_status to ingest channel …
Browse files Browse the repository at this point in the history
…ana table (#523)

The current RnR domain generator looks at the admin.ingest_status table to determine the latest AnA reference time that was ingested into the DB. One of our latest PRs actually removed the logging to the DB table and caused the RnR domain generator to be stuck on using an old reference time.

This fix will make the RnR domain generator point to the ingest.nwm_channel_ana table instead to get the reference time, which will actually be more of a valid query anyway
  • Loading branch information
CoreyKrewson-NOAA authored Sep 7, 2023
1 parent ad6d7d6 commit 42f5fdc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def lambda_handler(event, context):
result = cur.fetchone()
connection.commit()

reference_time = result[0].strftime(DT_FORMAT)
reference_time = dt.datetime.strptime(result[0], '%Y-%m-%d %H:%M:%S UTC').strftime(DT_FORMAT)
run_time_obj = dt.datetime.strptime(event['run_time'], '%Y-%m-%dT%H:%M:%SZ')
run_time = run_time_obj.strftime(DT_FORMAT)

Expand Down
14 changes: 4 additions & 10 deletions Core/LAMBDA/rnr_functions/rnr_domain_generator/sql/domain.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ WITH

ref_time AS (
SELECT reference_time
FROM admin.ingest_status
WHERE target = 'ingest.nwm_channel_rt_ana'
AND status = 'Import Complete'
FROM ingest.nwm_channel_rt_ana
ORDER BY reference_time DESC LIMIT 1
),

Expand Down Expand Up @@ -119,9 +117,7 @@ WITH RECURSIVE

ref_time AS (
SELECT reference_time
FROM admin.ingest_status
WHERE target = 'ingest.nwm_channel_rt_ana'
AND status = 'Import Complete'
FROM ingest.nwm_channel_rt_ana
ORDER BY reference_time DESC LIMIT 1
),

Expand Down Expand Up @@ -386,7 +382,5 @@ ORDER BY base.nws_station_id;
-------------------------------------------------------------
-------------------------------------------------------------
SELECT reference_time
FROM admin.ingest_status
WHERE target = 'ingest.nwm_channel_rt_ana'
AND status = 'Import Complete'
ORDER BY reference_time DESC LIMIT 1;
FROM ingest.nwm_channel_rt_ana
ORDER BY reference_time DESC LIMIT 1

0 comments on commit 42f5fdc

Please sign in to comment.