clean up logs (#149)

This commit is contained in:
Austin 2024-05-23 14:59:15 -04:00 committed by GitHub
parent 5abc7c1462
commit c9fabd832d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 28 additions and 1 deletions

View File

@ -49,4 +49,8 @@ jobs:
- name: Execute block_reorg macro
run: |
dbt run-operation fsc_utils.block_reorg --args "{reorg_model_list: '${{ steps.list_models.outputs.model_list }}', hours: '12'}" && awk '/SQL status/ {print; next} /DELETE FROM/{getline; print} /\/\* {/ {print}' logs/dbt.log
dbt run-operation fsc_utils.block_reorg --args "{reorg_model_list: '${{ steps.list_models.outputs.model_list }}', hours: '12'}" && awk '/SQL status/ {print; next} /DELETE FROM/{getline; print} /\/\* {/ {print}' logs/dbt.log
- name: Execute decoded_logs_cleanup macro
run: |
dbt run-operation decoded_logs_cleanup

View File

@ -0,0 +1,23 @@
{% macro decoded_logs_cleanup() %}
{% set sql %}
DELETE FROM
{{ ref('silver__decoded_logs') }}
d
WHERE
_inserted_timestamp > DATEADD('hour', -48, SYSDATE())
AND NOT EXISTS (
SELECT
1
FROM
{{ ref('silver__logs') }}
l
WHERE
d.block_number = l.block_number
AND d.tx_hash = l.tx_hash
AND d.event_index = l.event_index
AND d.contract_address = l.contract_address
AND d.topics [0] :: STRING = l.topics [0] :: STRING
);
{% endset %}
{% do run_query(sql) %}
{% endmacro %}