From 217e833756ad138f376576c95d39f7556b32acba Mon Sep 17 00:00:00 2001 From: dtookey Date: Fri, 8 Apr 2022 14:28:12 -0400 Subject: [PATCH] The issue appears to be the division prettification in lifecycle.sql. Changed it to simply grab the project type, we can grok the division info in datastudio --- src/sql/0-run-first/billing.sql | 15 +++++++-------- src/sql/0-run-first/lifecycle.sql | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/sql/0-run-first/billing.sql b/src/sql/0-run-first/billing.sql index caaea6c..be241cc 100644 --- a/src/sql/0-run-first/billing.sql +++ b/src/sql/0-run-first/billing.sql @@ -14,11 +14,10 @@ where invoice_accepted = 1; CREATE INDEX ref_num ON billing_report (refNumber); CREATE INDEX div_idx ON billing_report (division); -# So this little ditty will replace the raw project_type info with a prettified string. Only problem is it takes more than -# 10 minutes to run on our t3a.micro ec2 instance. -# UPDATE billing_report -# SET division = IF( -# division = 'Warranty', -# CONCAT(SUBSTRING(refNumber, 1, 3), ' - ', 'Structural'), -# CONCAT(SUBSTRING(refNumber, 1, 3), ' - ', division) -# ); + + UPDATE billing_report + SET division = IF( + division = 'Warranty', + CONCAT(SUBSTRING(refNumber, 1, 3), ' - ', 'Structural'), + CONCAT(SUBSTRING(refNumber, 1, 3), ' - ', division) + ); diff --git a/src/sql/0-run-first/lifecycle.sql b/src/sql/0-run-first/lifecycle.sql index 9606917..efcafb6 100644 --- a/src/sql/0-run-first/lifecycle.sql +++ b/src/sql/0-run-first/lifecycle.sql @@ -2,7 +2,7 @@ DROP TABLE IF EXISTS event_counts; CREATE TABLE event_counts AS SELECT DATE(timestamp) AS event_date, - get_division_collapsed(project_number) AS division, + all_projects.proj_type AS division_raw, if(substring(new_value, 1, 1) = '+', 1, -1) AS event_count, SUBSTRING(`new_value` FROM 2) AS flag FROM project_lifecycle