Skip to content

Commit 7456df4

Browse files
cli: pass-through normalize
1 parent f8034bc commit 7456df4

4 files changed

Lines changed: 5 additions & 2 deletions

File tree

audit.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ SELECT
1010
CAST(TRIM(REPLACE(REPLACE(REPLACE(total,'',''),'$',''),',','')) AS REAL) AS paid,
1111
CASE WHEN total LIKE '%$%' THEN 'usd' ELSE 'eur' END AS currency,
1212
grouping
13-
FROM raw_invoices
13+
FROM invoices
1414
WHERE product LIKE '%Cloud Server%';
1515

1616
DROP VIEW IF EXISTS detected_group;

lib.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ build_db() {
146146
import_invoices "$db" "$data_dir"
147147
sqlite3 "$db" ".mode csv" ".import --skip 1 '$prices' prices"
148148
sqlite3 "$db" ".mode csv" ".import --skip 1 '$spec' server_types"
149+
sqlite3 "$db" < "$assets/normalize.sql"
149150
sqlite3 "$db" < "$assets/audit.sql"
150151
}
151152

normalize.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
DROP TABLE IF EXISTS invoices;
2+
CREATE TABLE invoices AS SELECT * FROM raw_invoices;

tests/fixtures.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ CSV
77

88
stage_assets() {
99
mkdir -p "$1/providers/hetzner"
10-
cp "$ROOT/schema.sql" "$ROOT/audit.sql" "$1/"
10+
cp "$ROOT/schema.sql" "$ROOT/audit.sql" "$ROOT/normalize.sql" "$1/"
1111
}
1212

1313
fixture_assets() {

0 commit comments

Comments
 (0)