Skip to content

Commit

Permalink
Removed the deletion for duplicate info history entries from validati…
Browse files Browse the repository at this point in the history
…ons and validation_results tables
  • Loading branch information
rishi-salunkhe-mettle committed Aug 2, 2024
1 parent 9f12911 commit f48b778
Showing 1 changed file with 0 additions and 14 deletions.
14 changes: 0 additions & 14 deletions scripts/history_cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,6 @@ while IFS=',' read -r col1 col2 col3 col4; do
QUERY=$(echo "DELETE FROM fhir_endpoints_info_history WHERE url='$col1' AND operation='U' AND requested_fhir_version='$col3' AND entered_at = '$col2';")
(docker exec -t lantern-back-end_postgres_1 psql -t -U${DB_USER} -d ${DB_NAME} -c "${QUERY}") || echo "Error deleting entry from the info history table"

# Delete corresponding entry from the validations table
QUERY=$(echo "DELETE FROM validations WHERE validation_result_id = '$col4';")
(docker exec -t lantern-back-end_postgres_1 psql -t -U${DB_USER} -d ${DB_NAME} -c "${QUERY}") || echo "Error deleting entry from the validations table"

# Check whether there are entries in the info table having the given validation_result_id
QUERY=$(echo "SELECT COUNT(*) FROM fhir_endpoints_info WHERE validation_result_id='$col4';")
COUNT=$(docker exec -t lantern-back-end_postgres_1 psql -t -U${DB_USER} -d ${DB_NAME} -c "${QUERY}") || echo "Error counting entries from the validation_results table"

# Delete corresponding entry from the validation results table ONLY IF the count is zero.
NUMBER=$(echo ${COUNT} | tr -cd '[[:digit:]]')
if [ "${NUMBER}" -eq "0" ]; then
QUERY=$(echo "DELETE FROM validation_results WHERE id = '$col4';")
(docker exec -t lantern-back-end_postgres_1 psql -t -U${DB_USER} -d ${DB_NAME} -c "${QUERY}") || echo "Error deleting entry from the validation_results table"
fi
done < "$csv_file"

echo "Duplicate info history data cleanup complete."

0 comments on commit f48b778

Please sign in to comment.