Skip to content

Commit

Permalink
Added condition to fetch latest data before query interval start date…
Browse files Browse the repository at this point in the history
… to a SQL statement
  • Loading branch information
rishi-salunkhe-mettle committed Aug 15, 2024
1 parent 24e0ed6 commit 72693d0
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,13 @@ func prepareHistoryPruningStatements(s *Store) error {
WHERE (operation='U' OR operation='I')
AND url = $1
AND (date_trunc('minute', entered_at) <= date_trunc('minute', current_date - INTERVAL '` + thresholdString + ` minute'))
AND (date_trunc('minute', entered_at) >= date_trunc('minute', current_date - INTERVAL '` + queryIntString + ` minute'))
AND (date_trunc('minute', entered_at) >= COALESCE((SELECT date_trunc('minute', entered_at)
FROM fhir_endpoints_info_history
WHERE (operation='U' OR operation='I')
AND (date_trunc('minute', entered_at) < date_trunc('minute', current_date - INTERVAL '` + queryIntString + ` minute'))
AND url = $1
ORDER BY entered_at DESC LIMIT 1),
date_trunc('minute', current_date - INTERVAL '` + queryIntString + ` minute')))
ORDER BY entered_at ASC;`)
if err != nil {
return err
Expand Down

0 comments on commit 72693d0

Please sign in to comment.