update readme

This commit is contained in:
Paul Trowbridge 2022-04-12 23:31:31 -04:00
parent d35bc49f6f
commit 80bcb23170
2 changed files with 11 additions and 9 deletions

View File

@ -1,13 +1,12 @@
pre-requisites
* setup postgres db with a username and password and database
* add this to .bashrc to quickly invoke command line connection `export PGD="psql -U ptrowbridge -d ubm -p 5433 -h 192.168.1.110"`
setup
* `$PG -f setup_sql/schema.sql` setup the application tables
* `setup_sql/schema.sql` setup the application tables
* create a table of data to forecast
* `$PG -f setup_sql/target_info.sql` to populate the meta table (edit table name)
* `setup_sql/target_info.sql` to populate the meta table (edit table name)
* fill out the `target_meta` table
* `$PG -f setup_sql/build_maste_tables.sql` to create master data tables from forecast data
* `setup_sql/build_maste_tables.sql` to create master data tables from forecast data
* `./routes/baseline/generate_route_sql.sh` to create the baseline sql used by the /baseline route
| schema | tname | cname | opos | func | fkey | fcol | dtype | appcol | pretty |

View File

@ -11,6 +11,7 @@ SELECT
,o."Category"
,o."Party"
,o."Reason"
,o.app_units
,'app_forecast_name' "version"
,'actuals' iter
,null::bigint app_logid
@ -21,7 +22,7 @@ WHERE
--base period orders booked....
"Trans. Date" BETWEEN 'app_baseline_from_date'::date AND 'app_baseline_to_date'::date
--...or any open orders currently booked before cutoff....
OR ("Category" IN (app_openstatus_code) and "Trans. Date" <= 'app_openorder_cutoff'::date)
OR ("Description" IN (app_openstatus_code) and "Trans. Date" <= 'app_openorder_cutoff'::date)
--...or anything that shipped in that period
OR ("Post Date" BETWEEN 'app_baseline_from_date'::date AND 'app_baseline_to_date'::date)
)
@ -37,15 +38,16 @@ SELECT
,o."Category"
,o."Party"
,o."Reason"
,o.app_units
,'app_forecast_name' "version"
,'plug' iter
,null::bigint app_logid
FROM
tpsv.dcard o
LEFT OUTER JOIN fc.perd tdate ON
(o."Trans. Date" + interval '1 year' )::date <@ tdate.drange
LEFT OUTER JOIN fc.perd pdate ON
(o."Post Date" + interval '1 year' )::date <@ pdate.drange
LEFT OUTER JOIN fc.perd tdate ON
(o."Trans. Date" + interval '1 year' )::date <@ tdate.drange
WHERE
"Trans. Date" BETWEEN 'app_plug_fromdate'::date AND 'app_plug_todate'::date
--be sure to pre-exclude unwanted items, like canceled orders, non-gross sales, and short-ships
@ -61,15 +63,16 @@ SELECT
,o."Category"
,o."Party"
,o."Reason"
,o.app_units
,'app_forecast_name' "version"
,'baseline' iter
,null::bigint app_logid
FROM
baseline o
LEFT OUTER JOIN fc.perd tdate ON
(o."Trans. Date" + interval '1 year' )::date <@ tdate.drange
LEFT OUTER JOIN fc.perd pdate ON
(o."Post Date" + interval '1 year' )::date <@ pdate.drange
LEFT OUTER JOIN fc.perd tdate ON
(o."Trans. Date" + interval '1 year' )::date <@ tdate.drange
)
,ins AS (
INSERT INTO