diff options
author | Jesse Luehrs <doy@tozt.net> | 2019-08-27 00:23:44 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2019-08-27 00:23:44 -0400 |
commit | 82c986b34b7305303a402d49ce038fd65c4a7320 (patch) | |
tree | e4ae95636fa73e3661f651864c30cfd3a08e1fbc /modules | |
parent | 6f987ce645170dbbe340d9c758b8d13bf98b3267 (diff) | |
download | puppet-tozt-82c986b34b7305303a402d49ce038fd65c4a7320.tar.gz puppet-tozt-82c986b34b7305303a402d49ce038fd65c4a7320.zip |
use the cargo version of ynab-export
Diffstat (limited to 'modules')
-rw-r--r-- | modules/tozt/files/metabase | 28 | ||||
-rw-r--r-- | modules/tozt/manifests/metabase.pp | 12 |
2 files changed, 31 insertions, 9 deletions
diff --git a/modules/tozt/files/metabase b/modules/tozt/files/metabase index 3461a48..3557b23 100644 --- a/modules/tozt/files/metabase +++ b/modules/tozt/files/metabase @@ -1,5 +1,31 @@ #!/bin/sh set -eu -su doy /home/doy/coding/ynab-export/bin/load > /dev/null +tmp="$(mktemp --tmpdir -d metabase-cron.XXXXXXXXXX)" + +cleanup() { + if perl -e'exit 1 unless $ARGV[0] =~ m{^/tmp/metabase-cron.*$}' "$tmp"; then + rm -rf "$tmp" + fi +} +trap cleanup EXIT + +cd "$tmp" +su doy ynab-export + +psql -U metabase ynab < schema.sql +psql -U metabase ynab -c 'COPY accounts FROM STDIN' < accounts.tsv +psql -U metabase ynab -c 'COPY category_groups FROM STDIN' < category_groups.tsv +psql -U metabase ynab -c 'COPY categories FROM STDIN' < categories.tsv +psql -U metabase ynab -c 'COPY months FROM STDIN' < months.tsv +psql -U metabase ynab -c 'COPY categories_by_month FROM STDIN' < categories_by_month.tsv +psql -U metabase ynab -c 'COPY payees FROM STDIN' < payees.tsv +psql -U metabase ynab -c 'COPY transactions FROM STDIN' < transactions.tsv +psql -U metabase ynab -c 'COPY subtransactions FROM STDIN' < subtransactions.tsv +psql -U metabase ynab -c 'COPY scheduled_transactions FROM STDIN' < scheduled_transactions.tsv +psql -U metabase ynab -c 'COPY scheduled_subtransactions FROM STDIN' < scheduled_subtransactions.tsv + +seq 1000000 | psql -U metabase ynab -c 'COPY ints FROM STDIN' + +# shellcheck disable=SC2046 su doy /home/doy/coding/investments-sheet-export/bin/load $(cat /home/doy/.config/google/investments-sheet) > /dev/null diff --git a/modules/tozt/manifests/metabase.pp b/modules/tozt/manifests/metabase.pp index 2ece9b5..f8e3e7b 100644 --- a/modules/tozt/manifests/metabase.pp +++ b/modules/tozt/manifests/metabase.pp @@ -73,15 +73,11 @@ class tozt::metabase { require => File["/home/doy/.config/google"]; } - exec { "clone ynab-export": - command => "/usr/bin/git clone git://github.com/doy/ynab-export", + exec { "install ynab-export": + command => "/usr/bin/cargo install ynab-export", user => "doy", - cwd => "/home/doy/coding", - creates => "/home/doy/coding/ynab-export", - require => [ - Class["git"], - File["/home/doy/coding"], - ], + creates => "/home/doy/.cargo/bin/ynab-export", + require => Rust::User['doy']; } exec { "clone investments-sheet-export": |