Skip to content

Commit

Permalink
kingfisher-collect(incremental): Add transaction to replace _result t…
Browse files Browse the repository at this point in the history
…able
  • Loading branch information
jpmckinney committed May 1, 2024
1 parent 1b07605 commit 407f140
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion salt/kingfisher/collect/files/bi/cron.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ env SENTRY_DSN={{ SENTRY_DSN }} .ve/bin/scrapy crawl \
--logfile="{{ userdir }}/logs/{{ crawl.spider }}-$(date +%F).log"

# shellcheck disable=all
{%- if crawl.powerbi %}
{%- if 'powerbi' in crawl and crawl.powerbi %}
psql -U kingfisher_collect -h localhost -t -c 'SELECT data FROM {{ crawl.spider }}' -o {{ scratchdir }}/{{ crawl.spider }}.jsonl

ocdscardinal prepare \
Expand All @@ -32,6 +32,9 @@ ocdscardinal indicators \
{{ userdir }}/bin/manage.py json-to-csv {{ scratchdir }}/{{ crawl.spider }}.json {{ scratchdir }}/{{ crawl.spider }}.csv

psql postgresql://kingfisher_collect@localhost:5432/kingfisher_collect \
-c "BEGIN" \
-c "DELETE FROM {{ crawl.spider }}_result" \
-c "\copy {{ crawl.spider }}_result (ocid, subject, code, result, buyer_id, procuring_entity_id, tenderer_id, created_at) FROM stdin DELIMITER ',' CSV HEADER" \
-c "END" \
< {{scratchdir}}/{{crawl.spider}}.csv
{%- endif %}

0 comments on commit 407f140

Please sign in to comment.