customer review initial build

This commit is contained in:
Paul Trowbridge 2023-12-04 12:09:51 -05:00
commit 2b863dc492
11 changed files with 484 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.env
.vscode/

75
api.ts Normal file
View File

@ -0,0 +1,75 @@
import { Application, Router } from 'https://deno.land/x/oak/mod.ts';
import { Client } from "https://deno.land/x/postgres@v0.17.0/mod.ts";
import { load } from "https://deno.land/std/dotenv/mod.ts";
const app = new Application();
const router = new Router();
const env = await load();
const hostname = env["HOSTNAME"];
const port = env["PORT"];
const user = env["USER"];
const password = env["PASSWORD"];
const database = env["DATABASE"];
const app_port = env["APP_PORT"];
// Configure database connection
const client = new Client({
hostname:hostname
,port: port
,user: user
,password:password
,database:database
,applicationName: "customer review"
});
await client.connect();
// Load SQL from file
const query = await Deno.readTextFile("sql/write_note.sql");
router.post('/cust_review', async (ctx) => {
try {
const currentTime = new Date().toLocaleString('en-US', { timeZone: 'America/New_York' });
console.log("------------------------",currentTime,"-----------------------------")
const clientIp = ctx.request.ip;
console.log('Client IP:', clientIp);
//console.log('URL:', ctx.request.url);
//console.log('Method:', ctx.request.method);
// Log headers
//console.log('Headers:', [...ctx.request.headers].map(header => `${header[0]}: ${header[1]}`).join(', '));
// Get the body object to log the type
//const body = await ctx.request.body();
//console.log('Body Type:', body.type); // Logging the body type
// Log the body as text
const bodyText = await ctx.request.body({ type: 'text' }).value;
console.log('Body Text:', bodyText);
// If you expect a JSON body, you can then parse it
if (ctx.request.hasBody) {
const body = JSON.parse(bodyText);
console.log("Body JSON:", body);
const { bill_cust, ship_cust, expected, expecteduom} = body; // Destructure the needed values from the JSON
const result = await client.queryObject({args: [bill_cust, ship_cust, expected, expecteduom], text: query} );
}
} catch (error) {
console.error('Error:', error.message);
ctx.response.status = 500;
ctx.response.body = { error: 'Internal Server Error' };
}
});
app.use(router.routes());
app.use(router.allowedMethods());
// Start the server
console.log('Server is running on http://localhost:8087');
await app.listen({ port: 8087 });

13
customer_review.service Normal file
View File

@ -0,0 +1,13 @@
[Unit]
Description=Deno API Customer Review
After=network.target
[Service]
ExecStart=/home/ptrowbridge/.deno/bin/deno run --allow-all /opt/cust_review/api.ts
WorkingDirectory=/opt/cust_review
Restart=always
User=ptrowbridge
[Install]
WantedBy=multi-user.target

5
deno.json Normal file
View File

@ -0,0 +1,5 @@
{
"tasks": {
"dev": "deno run --watch main.ts"
}
}

193
deno.lock Normal file
View File

@ -0,0 +1,193 @@
{
"version": "3",
"redirects": {
"https://deno.land/std/dotenv/mod.ts": "https://deno.land/std@0.200.0/dotenv/mod.ts",
"https://deno.land/x/oak/mod.ts": "https://deno.land/x/oak@v12.6.0/mod.ts"
},
"remote": {
"https://deno.land/std@0.160.0/_util/assert.ts": "e94f2eb37cebd7f199952e242c77654e43333c1ac4c5c700e929ea3aa5489f74",
"https://deno.land/std@0.160.0/_util/os.ts": "8a33345f74990e627b9dfe2de9b040004b08ea5146c7c9e8fe9a29070d193934",
"https://deno.land/std@0.160.0/async/abortable.ts": "87aa7230be8360c24ad437212311c9e8d4328854baec27b4c7abb26e85515c06",
"https://deno.land/std@0.160.0/async/deadline.ts": "48ac998d7564969f3e6ec6b6f9bf0217ebd00239b1b2292feba61272d5dd58d0",
"https://deno.land/std@0.160.0/async/debounce.ts": "dc8b92d4a4fe7eac32c924f2b8d3e62112530db70cadce27042689d82970b350",
"https://deno.land/std@0.160.0/async/deferred.ts": "d8fb253ffde2a056e4889ef7e90f3928f28be9f9294b6505773d33f136aab4e6",
"https://deno.land/std@0.160.0/async/delay.ts": "0419dfc993752849692d1f9647edf13407c7facc3509b099381be99ffbc9d699",
"https://deno.land/std@0.160.0/async/mod.ts": "dd0a8ed4f3984ffabe2fcca7c9f466b7932d57b1864ffee148a5d5388316db6b",
"https://deno.land/std@0.160.0/async/mux_async_iterator.ts": "3447b28a2a582224a3d4d3596bccbba6e85040da3b97ed64012f7decce98d093",
"https://deno.land/std@0.160.0/async/pool.ts": "ef9eb97b388543acbf0ac32647121e4dbe629236899586c4d4311a8770fbb239",
"https://deno.land/std@0.160.0/async/tee.ts": "9af3a3e7612af75861308b52249e167f5ebc3dcfc8a1a4d45462d96606ee2b70",
"https://deno.land/std@0.160.0/bytes/bytes_list.ts": "aba5e2369e77d426b10af1de0dcc4531acecec27f9b9056f4f7bfbf8ac147ab4",
"https://deno.land/std@0.160.0/bytes/equals.ts": "3c3558c3ae85526f84510aa2b48ab2ad7bdd899e2e0f5b7a8ffc85acb3a6043a",
"https://deno.land/std@0.160.0/bytes/mod.ts": "b2e342fd3669176a27a4e15061e9d588b89c1aaf5008ab71766e23669565d179",
"https://deno.land/std@0.160.0/crypto/_fnv/fnv32.ts": "aa9bddead8c6345087d3abd4ef35fb9655622afc333fc41fff382b36e64280b5",
"https://deno.land/std@0.160.0/crypto/_fnv/fnv64.ts": "625d7e7505b6cb2e9801b5fd6ed0a89256bac12b2bbb3e4664b85a88b0ec5bef",
"https://deno.land/std@0.160.0/crypto/_fnv/index.ts": "a8f6a361b4c6d54e5e89c16098f99b6962a1dd6ad1307dbc97fa1ecac5d7060a",
"https://deno.land/std@0.160.0/crypto/_fnv/util.ts": "4848313bed7f00f55be3cb080aa0583fc007812ba965b03e4009665bde614ce3",
"https://deno.land/std@0.160.0/crypto/_wasm_crypto/lib/deno_std_wasm_crypto.generated.mjs": "258b484c2da27578bec61c01d4b62c21f72268d928d03c968c4eb590cb3bd830",
"https://deno.land/std@0.160.0/crypto/_wasm_crypto/mod.ts": "6c60d332716147ded0eece0861780678d51b560f533b27db2e15c64a4ef83665",
"https://deno.land/std@0.160.0/crypto/keystack.ts": "e481eed28007395e554a435e880fee83a5c73b9259ed8a135a75e4b1e4f381f7",
"https://deno.land/std@0.160.0/crypto/mod.ts": "fadedc013b4a86fda6305f1adc6d1c02225834d53cff5d95cc05f62b25127517",
"https://deno.land/std@0.160.0/crypto/timing_safe_equal.ts": "82a29b737bc8932d75d7a20c404136089d5d23629e94ba14efa98a8cc066c73e",
"https://deno.land/std@0.160.0/datetime/formatter.ts": "7c8e6d16a0950f400aef41b9f1eb9168249869776ec520265dfda785d746589e",
"https://deno.land/std@0.160.0/datetime/mod.ts": "ea927ca96dfb28c7b9a5eed5bdc7ac46bb9db38038c4922631895cea342fea87",
"https://deno.land/std@0.160.0/datetime/tokenizer.ts": "7381e28f6ab51cb504c7e132be31773d73ef2f3e1e50a812736962b9df1e8c47",
"https://deno.land/std@0.160.0/encoding/base64.ts": "c57868ca7fa2fbe919f57f88a623ad34e3d970d675bdc1ff3a9d02bba7409db2",
"https://deno.land/std@0.160.0/encoding/base64url.ts": "a5f82a9fa703bd85a5eb8e7c1296bc6529e601ebd9642cc2b5eaa6b38fa9e05a",
"https://deno.land/std@0.160.0/encoding/hex.ts": "4cc5324417cbb4ac9b828453d35aed45b9cc29506fad658f1f138d981ae33795",
"https://deno.land/std@0.160.0/fmt/colors.ts": "9e36a716611dcd2e4865adea9c4bec916b5c60caad4cdcdc630d4974e6bb8bd4",
"https://deno.land/std@0.160.0/io/buffer.ts": "fae02290f52301c4e0188670e730cd902f9307fb732d79c4aa14ebdc82497289",
"https://deno.land/std@0.160.0/path/_constants.ts": "df1db3ffa6dd6d1252cc9617e5d72165cd2483df90e93833e13580687b6083c3",
"https://deno.land/std@0.160.0/path/_interface.ts": "ee3b431a336b80cf445441109d089b70d87d5e248f4f90ff906820889ecf8d09",
"https://deno.land/std@0.160.0/path/_util.ts": "d16be2a16e1204b65f9d0dfc54a9bc472cafe5f4a190b3c8471ec2016ccd1677",
"https://deno.land/std@0.160.0/path/common.ts": "bee563630abd2d97f99d83c96c2fa0cca7cee103e8cb4e7699ec4d5db7bd2633",
"https://deno.land/std@0.160.0/path/glob.ts": "cb5255638de1048973c3e69e420c77dc04f75755524cb3b2e160fe9277d939ee",
"https://deno.land/std@0.160.0/path/mod.ts": "56fec03ad0ebd61b6ab39ddb9b0ddb4c4a5c9f2f4f632e09dd37ec9ebfd722ac",
"https://deno.land/std@0.160.0/path/posix.ts": "6b63de7097e68c8663c84ccedc0fd977656eb134432d818ecd3a4e122638ac24",
"https://deno.land/std@0.160.0/path/separator.ts": "fe1816cb765a8068afb3e8f13ad272351c85cbc739af56dacfc7d93d710fe0f9",
"https://deno.land/std@0.160.0/path/win32.ts": "ee8826dce087d31c5c81cd414714e677eb68febc40308de87a2ce4b40e10fb8d",
"https://deno.land/std@0.160.0/testing/_diff.ts": "a23e7fc2b4d8daa3e158fa06856bedf5334ce2a2831e8bf9e509717f455adb2c",
"https://deno.land/std@0.160.0/testing/_format.ts": "cd11136e1797791045e639e9f0f4640d5b4166148796cad37e6ef75f7d7f3832",
"https://deno.land/std@0.160.0/testing/asserts.ts": "1e340c589853e82e0807629ba31a43c84ebdcdeca910c4a9705715dfdb0f5ce8",
"https://deno.land/std@0.193.0/_util/asserts.ts": "178dfc49a464aee693a7e285567b3d0b555dc805ff490505a8aae34f9cfb1462",
"https://deno.land/std@0.193.0/_util/os.ts": "d932f56d41e4f6a6093d56044e29ce637f8dcc43c5a90af43504a889cf1775e3",
"https://deno.land/std@0.193.0/async/deferred.ts": "42790112f36a75a57db4a96d33974a936deb7b04d25c6084a9fa8a49f135def8",
"https://deno.land/std@0.193.0/bytes/bytes_list.ts": "31d664f4d42fa922066405d0e421c56da89d751886ee77bbe25a88bf0310c9d0",
"https://deno.land/std@0.193.0/bytes/concat.ts": "d26d6f3d7922e6d663dacfcd357563b7bf4a380ce5b9c2bbe0c8586662f25ce2",
"https://deno.land/std@0.193.0/bytes/copy.ts": "939d89e302a9761dcf1d9c937c7711174ed74c59eef40a1e4569a05c9de88219",
"https://deno.land/std@0.193.0/bytes/ends_with.ts": "4228811ebc71615d27f065c54b5e815ec1972538772b0f413c0efe05245b472e",
"https://deno.land/std@0.193.0/bytes/equals.ts": "fc190cce412b2136979181b163ec7e05f7e7a947e39102eee4b8c0d62519ddf9",
"https://deno.land/std@0.193.0/bytes/includes_needle.ts": "76a8163126fb2f8bf86fd7f22192c3bb04bf6a20b987a095127c2ca08adf3ba6",
"https://deno.land/std@0.193.0/bytes/index_of_needle.ts": "9c06610e9611b5647ac25952e71a22e09227c9f1b8cbeeb33399bf8bf8a7f649",
"https://deno.land/std@0.193.0/bytes/last_index_of_needle.ts": "f1602f221c3b678bc4f1e1c88a70a15ab7da32c21751dbbc6c957c956951d784",
"https://deno.land/std@0.193.0/bytes/mod.ts": "e869bba1e7a2e3a9cc6c2d55471888429a544e70a840c087672e656e7ba21815",
"https://deno.land/std@0.193.0/bytes/repeat.ts": "6f5e490d8d72bcbf8d84a6bb04690b9b3eb5822c5a11687bca73a2318a842294",
"https://deno.land/std@0.193.0/bytes/starts_with.ts": "3e607a70c9c09f5140b7a7f17a695221abcc7244d20af3eb47ccbb63f5885135",
"https://deno.land/std@0.193.0/crypto/keystack.ts": "877ab0f19eb7d37ad6495190d3c3e39f58e9c52e0b6a966f82fd6df67ca55f90",
"https://deno.land/std@0.193.0/crypto/timing_safe_equal.ts": "0fae34ee02264f309ae0b6e54e9746a7aba3996e5454903ed106967a7a9ef665",
"https://deno.land/std@0.193.0/encoding/base64.ts": "144ae6234c1fbe5b68666c711dc15b1e9ee2aef6d42b3b4345bf9a6c91d70d0d",
"https://deno.land/std@0.193.0/encoding/base64url.ts": "2ed4ba122b20fedf226c5d337cf22ee2024fa73a8f85d915d442af7e9ce1fae1",
"https://deno.land/std@0.193.0/http/_negotiation/common.ts": "14d1a52427ab258a4b7161cd80e1d8a207b7cc64b46e911780f57ead5f4323c6",
"https://deno.land/std@0.193.0/http/_negotiation/encoding.ts": "ff747d107277c88cb7a6a62a08eeb8d56dad91564cbcccb30694d5dc126dcc53",
"https://deno.land/std@0.193.0/http/_negotiation/language.ts": "7bcddd8db3330bdb7ce4fc00a213c5547c1968139864201efd67ef2d0d51887d",
"https://deno.land/std@0.193.0/http/_negotiation/media_type.ts": "58847517cd549384ad677c0fe89e0a4815be36fe7a303ea63cee5f6a1d7e1692",
"https://deno.land/std@0.193.0/http/cookie_map.ts": "d148a5eaf35f19905dd5104126fa47ac71105306dd42f129732365e43108b28a",
"https://deno.land/std@0.193.0/http/etag.ts": "6ad8abbbb1045aabf2307959a2c5565054a8bf01c9824ddee836b1ff22706a58",
"https://deno.land/std@0.193.0/http/http_errors.ts": "bbda34819060af86537cecc9dc8e045f877130808b7e7acde4197c5328e852d0",
"https://deno.land/std@0.193.0/http/http_status.ts": "8a7bcfe3ac025199ad804075385e57f63d055b2aed539d943ccc277616d6f932",
"https://deno.land/std@0.193.0/http/method.ts": "e66c2a015cb46c21ab0bb3589aa4fca43143a506cb324ffdfd42d2edef7bc0c4",
"https://deno.land/std@0.193.0/http/negotiation.ts": "46e74a6bad4b857333a58dc5b50fe8e5a4d5267e97292293ea65f980bd918086",
"https://deno.land/std@0.193.0/http/server_sent_event.ts": "1f3597d175e8935123306a24d7f4423a463667a70953d17b4115af1880459d55",
"https://deno.land/std@0.193.0/http/user_agent.ts": "6f4308670f261118cc6a1518bf37431a5b4f21322b4a4edf0963e182264ce404",
"https://deno.land/std@0.193.0/io/buf_reader.ts": "06fff3337091c49e99ebd2dd790c9a90364c087a2953ea081667400fd6c6cebb",
"https://deno.land/std@0.193.0/io/buf_writer.ts": "48c33c8f00b61dcbc7958706741cec8e59810bd307bc6a326cbd474fe8346dfd",
"https://deno.land/std@0.193.0/io/buffer.ts": "17f4410eaaa60a8a85733e8891349a619eadfbbe42e2f319283ce2b8f29723ab",
"https://deno.land/std@0.193.0/io/copy_n.ts": "0cc7ce07c75130f6fc18621ec1911c36e147eb9570664fee0ea12b1988167590",
"https://deno.land/std@0.193.0/io/limited_reader.ts": "6c9a216f8eef39c1ee2a6b37a29372c8fc63455b2eeb91f06d9646f8f759fc8b",
"https://deno.land/std@0.193.0/io/mod.ts": "2665bcccc1fd6e8627cca167c3e92aaecbd9897556b6f69e6d258070ef63fd9b",
"https://deno.land/std@0.193.0/io/multi_reader.ts": "9c2a0a31686c44b277e16da1d97b4686a986edcee48409b84be25eedbc39b271",
"https://deno.land/std@0.193.0/io/read_delim.ts": "c02b93cc546ae8caad8682ae270863e7ace6daec24c1eddd6faabc95a9d876a3",
"https://deno.land/std@0.193.0/io/read_int.ts": "7cb8bcdfaf1107586c3bacc583d11c64c060196cb070bb13ae8c2061404f911f",
"https://deno.land/std@0.193.0/io/read_lines.ts": "c526c12a20a9386dc910d500f9cdea43cba974e853397790bd146817a7eef8cc",
"https://deno.land/std@0.193.0/io/read_long.ts": "f0aaa420e3da1261c5d33c5e729f09922f3d9fa49f046258d4ff7a00d800c71e",
"https://deno.land/std@0.193.0/io/read_range.ts": "28152daf32e43dd9f7d41d8466852b0d18ad766cd5c4334c91fef6e1b3a74eb5",
"https://deno.land/std@0.193.0/io/read_short.ts": "805cb329574b850b84bf14a92c052c59b5977a492cd780c41df8ad40826c1a20",
"https://deno.land/std@0.193.0/io/read_string_delim.ts": "5dc9f53bdf78e7d4ee1e56b9b60352238ab236a71c3e3b2a713c3d78472a53ce",
"https://deno.land/std@0.193.0/io/slice_long_to_bytes.ts": "48d9bace92684e880e46aa4a2520fc3867f9d7ce212055f76ecc11b22f9644b7",
"https://deno.land/std@0.193.0/io/string_reader.ts": "da0f68251b3d5b5112485dfd4d1b1936135c9b4d921182a7edaf47f74c25cc8f",
"https://deno.land/std@0.193.0/io/string_writer.ts": "8a03c5858c24965a54c6538bed15f32a7c72f5704a12bda56f83a40e28e5433e",
"https://deno.land/std@0.193.0/media_types/_db.ts": "7606d83e31f23ce1a7968cbaee852810c2cf477903a095696cdc62eaab7ce570",
"https://deno.land/std@0.193.0/media_types/_util.ts": "916efbd30b6148a716f110e67a4db29d6949bf4048997b754415dd7e42c52378",
"https://deno.land/std@0.193.0/media_types/content_type.ts": "ad98a5aa2d95f5965b2796072284258710a25e520952376ed432b0937ce743bc",
"https://deno.land/std@0.193.0/media_types/extension.ts": "a7cd28c9417143387cdfed27d4e8607ebcf5b1ec27eb8473d5b000144689fe65",
"https://deno.land/std@0.193.0/media_types/extensions_by_type.ts": "43806d6a52a0d6d965ada9d20e60a982feb40bc7a82268178d94edb764694fed",
"https://deno.land/std@0.193.0/media_types/format_media_type.ts": "f5e1073c05526a6f5a516ac5c5587a1abd043bf1039c71cde1166aa4328c8baf",
"https://deno.land/std@0.193.0/media_types/get_charset.ts": "18b88274796fda5d353806bf409eb1d2ddb3f004eb4bd311662c4cdd8ac173db",
"https://deno.land/std@0.193.0/media_types/mod.ts": "d3f0b99f85053bc0b98ecc24eaa3546dfa09b856dc0bbaf60d8956d2cdd710c8",
"https://deno.land/std@0.193.0/media_types/parse_media_type.ts": "835c4112e1357e95b4f10d7cdea5ae1801967e444f48673ff8f1cb4d32af9920",
"https://deno.land/std@0.193.0/media_types/type_by_extension.ts": "daa801eb0f11cdf199445d0f1b656cf116d47dcf9e5b85cc1e6b4469f5ee0432",
"https://deno.land/std@0.193.0/media_types/vendor/mime-db.v1.52.0.ts": "6925bbcae81ca37241e3f55908d0505724358cda3384eaea707773b2c7e99586",
"https://deno.land/std@0.193.0/path/_constants.ts": "e49961f6f4f48039c0dfed3c3f93e963ca3d92791c9d478ac5b43183413136e0",
"https://deno.land/std@0.193.0/path/_interface.ts": "6471159dfbbc357e03882c2266d21ef9afdb1e4aa771b0545e90db58a0ba314b",
"https://deno.land/std@0.193.0/path/_util.ts": "d7abb1e0dea065f427b89156e28cdeb32b045870acdf865833ba808a73b576d0",
"https://deno.land/std@0.193.0/path/common.ts": "ee7505ab01fd22de3963b64e46cff31f40de34f9f8de1fff6a1bd2fe79380000",
"https://deno.land/std@0.193.0/path/glob.ts": "d479e0a695621c94d3fd7fe7abd4f9499caf32a8de13f25073451c6ef420a4e1",
"https://deno.land/std@0.193.0/path/mod.ts": "f065032a7189404fdac3ad1a1551a9ac84751d2f25c431e101787846c86c79ef",
"https://deno.land/std@0.193.0/path/posix.ts": "8b7c67ac338714b30c816079303d0285dd24af6b284f7ad63da5b27372a2c94d",
"https://deno.land/std@0.193.0/path/separator.ts": "0fb679739d0d1d7bf45b68dacfb4ec7563597a902edbaf3c59b50d5bcadd93b1",
"https://deno.land/std@0.193.0/path/win32.ts": "d186344e5583bcbf8b18af416d13d82b35a317116e6460a5a3953508c3de5bba",
"https://deno.land/std@0.193.0/streams/_common.ts": "f45cba84f0d813de3326466095539602364a9ba521f804cc758f7a475cda692d",
"https://deno.land/std@0.193.0/streams/buffer.ts": "d5b3d7d0299114e5b2ea895a8bf202a687fd915c5282f8096c7bae23b5a04407",
"https://deno.land/std@0.193.0/streams/byte_slice_stream.ts": "225d57263a34325d7c96cb3dafeb478eec0e6fd05cd0458d678752eadd132bb4",
"https://deno.land/std@0.193.0/streams/copy.ts": "75cbc795ff89291df22ddca5252de88b2e16d40c85d02840593386a8a1454f71",
"https://deno.land/std@0.193.0/streams/delimiter_stream.ts": "f69e849b3d1f59f02424497273f411105a6f76a9f13da92aeeb9a2d554236814",
"https://deno.land/std@0.193.0/streams/early_zip_readable_streams.ts": "4005fa74162b943f79899e5d7cb96adcbc0a6b867f9144974ed12d30e0a556e1",
"https://deno.land/std@0.193.0/streams/iterate_reader.ts": "bbec1d45c2df2c0c5920bad0549351446fdc8e0886d99e95959b259dbcdb6072",
"https://deno.land/std@0.193.0/streams/limited_bytes_transform_stream.ts": "05dc592ffaab83257494d22dd53917e56243c26e5e3129b3f13ddbbbc4785048",
"https://deno.land/std@0.193.0/streams/limited_transform_stream.ts": "d69ab790232c1b86f53621ad41ef03c235f2abb4b7a1cd51960ad6e12ee55e38",
"https://deno.land/std@0.193.0/streams/merge_readable_streams.ts": "dc2db0cbf1b14d999aa2aa2a2a1ba24ce58953878f29845ed9319321d0a01fab",
"https://deno.land/std@0.193.0/streams/mod.ts": "c07ec010e700b9ea887dc36ca08729828bc7912f711e4054e24d33fd46282252",
"https://deno.land/std@0.193.0/streams/read_all.ts": "ee319772fb0fd28302f97343cc48dfcf948f154fd0d755d8efe65814b70533be",
"https://deno.land/std@0.193.0/streams/readable_stream_from_iterable.ts": "cd4bb9e9bf6dbe84c213beb1f5085c326624421671473e410cfaecad15f01865",
"https://deno.land/std@0.193.0/streams/readable_stream_from_reader.ts": "bfc416c4576a30aac6b9af22c9dc292c20c6742141ee7c55b5e85460beb0c54e",
"https://deno.land/std@0.193.0/streams/reader_from_iterable.ts": "55f68110dce3f8f2c87b834d95f153bc904257fc65175f9f2abe78455cb8047c",
"https://deno.land/std@0.193.0/streams/reader_from_stream_reader.ts": "fa4971e5615a010e49492c5d1688ca1a4d17472a41e98b498ab89a64ebd7ac73",
"https://deno.land/std@0.193.0/streams/text_delimiter_stream.ts": "20e680ab8b751390e359288ce764f9c47d164af11a263870746eeca4bc7d976b",
"https://deno.land/std@0.193.0/streams/text_line_stream.ts": "0f2c4b33a5fdb2476f2e060974cba1347cefe99a4af33c28a57524b1a34750fa",
"https://deno.land/std@0.193.0/streams/to_transform_stream.ts": "7f55fc0b14cf3ed0f8d10d8f41d05bdc40726e44a65c37f58705d10a615f0159",
"https://deno.land/std@0.193.0/streams/writable_stream_from_writer.ts": "56fff5c82fb736fdd669b567cc0b2bbbe0351002cd13254eae26c366e2bed89a",
"https://deno.land/std@0.193.0/streams/write_all.ts": "aec90152978581ea62d56bb53a5cbf487e6a89c902f87c5969681ffbdf32b998",
"https://deno.land/std@0.193.0/streams/writer_from_stream_writer.ts": "07c7ee025151a190f37fc42cbb01ff93afc949119ebddc6e0d0df14df1bf6950",
"https://deno.land/std@0.193.0/streams/zip_readable_streams.ts": "a9d81aa451240f79230add674809dbee038d93aabe286e2d9671e66591fc86ca",
"https://deno.land/std@0.200.0/collections/filter_values.ts": "16e1fc456a7969e770ec5b89edf5ac97b295ca534b47c1a83f061b409aad7814",
"https://deno.land/std@0.200.0/collections/without_all.ts": "1e3cccb1ed0659455b473c0766d9414b7710d8cef48862c899f445178f66b779",
"https://deno.land/std@0.200.0/dotenv/mod.ts": "2caa157ee5afbf74bd85bd6e8f286cb6363a1e4d10cf3376223346b33a7ea75e",
"https://deno.land/x/oak@v12.6.0/application.ts": "3028d3f6fa5ee743de013881550d054372c11d83c45099c2d794033786d27008",
"https://deno.land/x/oak@v12.6.0/body.ts": "1899761b97fc9d776f3710b2637fb047ba29b968609afc6c0e5219b1108e703c",
"https://deno.land/x/oak@v12.6.0/buf_reader.ts": "26640736541598dbd9f2b84a9d0595756afff03c9ca55b66eef1911f7798b56d",
"https://deno.land/x/oak@v12.6.0/content_disposition.ts": "8b8c3cb2fba7138cd5b7f82fc3b5ea39b33db924a824b28261659db7e164621e",
"https://deno.land/x/oak@v12.6.0/context.ts": "895a2d40186b89c28ba3947bf08a9335f1a11fc33133f760082536b74c53d1ca",
"https://deno.land/x/oak@v12.6.0/deps.ts": "6c601cd79f39489ad37d87587ad0c6fe53d838946ffa5a3e7e9600e7a01dc6d9",
"https://deno.land/x/oak@v12.6.0/etag.ts": "32e47726b41698aefdd71faac5aaf2907c9bdd41ef18a7693863be4f8fee115d",
"https://deno.land/x/oak@v12.6.0/forwarded.ts": "e656f96a85574e2a6ee54dc35efc9f72d543c9ae0923760ef426ee7369eef01c",
"https://deno.land/x/oak@v12.6.0/headers.ts": "769fd042d34fbcd5667cbd745b5c65d335cc8430e822dbf1f87d65313cab4b47",
"https://deno.land/x/oak@v12.6.0/helpers.ts": "6b03c6a2be06ec775d54449e442a2bac234aa952948ca758356eab6dc87af618",
"https://deno.land/x/oak@v12.6.0/http_server_native.ts": "6232bed3d7bc17136d1a7f7685a6f8a79c943694463f71cf743eac58e75ec34c",
"https://deno.land/x/oak@v12.6.0/http_server_native_request.ts": "552b174b5e13e92de8897d5b6f716b1e5a53543115481d65a651a41e4ca29ec9",
"https://deno.land/x/oak@v12.6.0/isMediaType.ts": "62d638abcf837ece3a8f07a4b7ca59794135cb0d4b73194c7d5837efd4161005",
"https://deno.land/x/oak@v12.6.0/mediaTyper.ts": "042b853fc8e9c3f6c628dd389e03ef481552bf07242efc3f8a1af042102a6105",
"https://deno.land/x/oak@v12.6.0/middleware.ts": "c7f7a0424a6dd99a00e4b8d7d6e131efc0facc8dea781845d713b63df8ef1862",
"https://deno.land/x/oak@v12.6.0/middleware/proxy.ts": "6f2799cf60d926e7a8d13ff757a59d7f0f930407db7ee9b81e7c064138eb89ff",
"https://deno.land/x/oak@v12.6.0/mod.ts": "f6aa47ad1b6099470c9a884cccad9d3ac0fd242ba940896291ab76cd26cf554b",
"https://deno.land/x/oak@v12.6.0/multipart.ts": "1484e01b98f5135f2aa09f7d0ce1e7be39109bf9f045ac660e941619d04e3d29",
"https://deno.land/x/oak@v12.6.0/range.ts": "1ca15fc1ac21c650c34e6997a75af2af9d9d8eb6fe2d5d1dadeac3dfd4a9c152",
"https://deno.land/x/oak@v12.6.0/request.ts": "794e5e12c2d369c2b8a6c998be5ca96c6e0315cae73069b85bc537901811073c",
"https://deno.land/x/oak@v12.6.0/response.ts": "7172285e58947057f36d6536b52a9cdffbdb03616555fa8e94b87f469a105f8a",
"https://deno.land/x/oak@v12.6.0/router.ts": "0f53d6249f9e8f89f2522b2b810b9302d0f22593c184b16b24b03bf2b7d42ea1",
"https://deno.land/x/oak@v12.6.0/send.ts": "5ec49f106294593f468317a0c885da4f3274bf6d0fe9e16a7304391730b4f4fb",
"https://deno.land/x/oak@v12.6.0/structured_clone.ts": "c3888b14d1eec558345bfbf13d0993d59bd45aaa8588444e35dd558c3a921cd8",
"https://deno.land/x/oak@v12.6.0/testing.ts": "37d684d57bb8e5150fb5eb2677e66b04dcb422709cf2c5a74c1df94d52aa02e2",
"https://deno.land/x/oak@v12.6.0/util.ts": "0a3fdffb114859c2de84e1783efa3a544af4d2af8c6f08e0d25655de9d3e69bb",
"https://deno.land/x/path_to_regexp@v6.2.1/index.ts": "894060567837bae8fc9c5cbd4d0a05e9024672083d5883b525c031eea940e556",
"https://deno.land/x/postgres@v0.17.0/client.ts": "348779c9f6a1c75ef1336db662faf08dce7d2101ff72f0d1e341ba1505c8431d",
"https://deno.land/x/postgres@v0.17.0/client/error.ts": "0817583b666fd546664ed52c1d37beccc5a9eebcc6e3c2ead20ada99b681e5f7",
"https://deno.land/x/postgres@v0.17.0/connection/auth.ts": "1070125e2ac4ca4ade36d69a4222d37001903092826d313217987583edd61ce9",
"https://deno.land/x/postgres@v0.17.0/connection/connection.ts": "428ed3efa055870db505092b5d3545ef743497b7b4b72cf8f0593e7dd4788acd",
"https://deno.land/x/postgres@v0.17.0/connection/connection_params.ts": "52bfe90e8860f584b95b1b08c254dde97c3aa763c4b6bee0c80c5930e35459e0",
"https://deno.land/x/postgres@v0.17.0/connection/message.ts": "f9257948b7f87d58bfbfe3fc6e2e08f0de3ef885655904d56a5f73655cc22c5a",
"https://deno.land/x/postgres@v0.17.0/connection/message_code.ts": "466719008b298770c366c5c63f6cf8285b7f76514dadb4b11e7d9756a8a1ddbf",
"https://deno.land/x/postgres@v0.17.0/connection/packet.ts": "050aeff1fc13c9349e89451a155ffcd0b1343dc313a51f84439e3e45f64b56c8",
"https://deno.land/x/postgres@v0.17.0/connection/scram.ts": "0c7a2551fe7b1a1c62dd856b7714731a7e7534ccca10093336782d1bfc5b2bd2",
"https://deno.land/x/postgres@v0.17.0/deps.ts": "f47ccb41f7f97eaad455d94f407ef97146ae99443dbe782894422c869fbba69e",
"https://deno.land/x/postgres@v0.17.0/mod.ts": "a1e18fd9e6fedc8bc24e5aeec3ae6de45e2274be1411fb66e9081420c5e81d7d",
"https://deno.land/x/postgres@v0.17.0/pool.ts": "892db7b5e1787988babecc994a151ebbd7d017f080905cbe9c3d7b44a73032a9",
"https://deno.land/x/postgres@v0.17.0/query/array_parser.ts": "f8a229d82c3801de8266fa2cc4afe12e94fef8d0c479e73655c86ed3667ef33f",
"https://deno.land/x/postgres@v0.17.0/query/decode.ts": "44a4a6cbcf494ed91a4fecae38a57dce63a7b519166f02c702791d9717371419",
"https://deno.land/x/postgres@v0.17.0/query/decoders.ts": "16cb0e60227d86692931e315421b15768c78526e3aeb84e25fcc4111096de9fd",
"https://deno.land/x/postgres@v0.17.0/query/encode.ts": "5f1418a2932b7c2231556e4a5f5f56efef48728014070cfafe7656963f342933",
"https://deno.land/x/postgres@v0.17.0/query/oid.ts": "8c33e1325f34e4ca9f11a48b8066c8cfcace5f64bc1eb17ad7247af4936999e1",
"https://deno.land/x/postgres@v0.17.0/query/query.ts": "edb473cbcfeff2ee1c631272afb25d079d06b66b5853f42492725b03ffa742b6",
"https://deno.land/x/postgres@v0.17.0/query/transaction.ts": "8e75c3ce0aca97da7fe126e68f8e6c08d640e5c8d2016e62cee5c254bebe7fe8",
"https://deno.land/x/postgres@v0.17.0/utils/deferred.ts": "dd94f2a57355355c47812b061a51b55263f72d24e9cb3fdb474c7519f4d61083",
"https://deno.land/x/postgres@v0.17.0/utils/utils.ts": "19c3527ddd5c6c4c49ae36397120274c7f41f9d3cbf479cb36065d23329e9f90"
}
}

8
main.ts Normal file
View File

@ -0,0 +1,8 @@
export function add(a: number, b: number): number {
return a + b;
}
// Learn more at https://deno.land/manual/examples/module_metadata#concepts
if (import.meta.main) {
console.log("Add 2 + 3 =", add(2, 3));
}

6
main_test.ts Normal file
View File

@ -0,0 +1,6 @@
import { assertEquals } from "https://deno.land/std@0.208.0/assert/mod.ts";
import { add } from "./main.ts";
Deno.test(function addTest() {
assertEquals(add(2, 3), 5);
});

8
readme.md Normal file
View File

@ -0,0 +1,8 @@
Customer
23 Shipments
24 STD Ships
24 Open to ship this season
be able to sort by delta
Back half order & ship

22
sql/excel_query.sql Normal file
View File

@ -0,0 +1,22 @@
SELECT
sw.bill_dba "Bill-To"
,sw.ship_dba "Ship-To"
,sw.dsm "DSM"
,sw.budget_2024 "2024 Budget"
,sw.shipments_2023 "2023 Shipments"
,sw.shipments_2024 "2024 Shipments"
,sw.open_orders_2024 "2024 Open Orders"
--sw.quotes "Quotes",
,(shipments_2024 + open_orders_2024) - budget_2024 "Budget Delta"
,(shipments_2024 + open_orders_2024) - shipments_2023 "YoY Delta"
,CASE sw.newuom WHEN 'Dollars' THEN sw.newords ELSE 0 END "Expected Dollars"
,CASE sw.newuom WHEN 'Pallets' THEN sw.newords ELSE 0 END "Expected Pallets"
,CASE sw.newuom WHEN 'Units' THEN sw.newords ELSE 0 END "Expected Units"
FROM
rlarp.cust_review sw
WHERE
TRUE
--(sw.dsm = ?)
ORDER BY
sw.shipments_2023 desc,
shipments_2024 + open_orders_2024 desc

140
sql/schema.pg.sql Normal file
View File

@ -0,0 +1,140 @@
/*
walk
sales_walk_agg
sales_walk
sales_walk_seg_agg
sales_walk_seg
*/
CREATE TABLE IF NOT EXISTS rlarp.customer_review (
bill_cust text
,ship_cust text
,newords numeric
,newuom text
,PRIMARY KEY (bill_cust, ship_cust)
);
GRANT ALL ON TABLE rlarp.customer_review TO PUBLIC;
DROP VIEW IF EXISTS rlarp.cust_review_seg;
DROP VIEW IF EXISTS rlarp.cust_review;
------------------------------------------sales walk agg---------------------------------------------------
DROP MATERIALIZED VIEW IF EXISTS rlarp.cust_review_agg ;
CREATE MATERIALIZED VIEW rlarp.cust_review_agg AS
WITH
act as (
SELECT
bill_dba
,ship_dba
,dsm
--,os.glec
--,m.biggroup
--,os.priceg
,COALESCE(sum(pounds) filter (WHERE sseas = 2023 AND version = 'Actual'),0) "Actual 2023"
,COALESCE(sum(pounds) filter (WHERE sseas = 2024 AND version = 'Actual'),0) "Actual 2024"
,COALESCE(sum(pounds) filter (WHERE version = 'Actual' AND ostatus LIKE 'Open%' AND rseas <= 2024),0) "Open Ord"
--,COALESCE(sum(pounds) filter (WHERE version = 'Quotes'),0) "Quotes"
FROM
rlarp.osm_stack os
LEFT OUTER JOIN rlarp.molds m ON
m.stlc = substring(os.product ,1,8)
WHERE
(
(
sseas IN (2023,2024)
AND version = 'Actual'
AND ostatus = 'Shipped'
)
--OR (
-- version = 'Quotes'
-- AND odate >= '2023-05-01'::date
--)
OR (ostatus LIKE 'Open%')
)
AND calc_status <> 'CANCELED'
AND substring(os.glec,1,1) <= '2'
AND os.fs_line = '41010'
AND COALESCE(ship_dba,'') <> ''
GROUP BY
bill_dba
,ship_dba
,dsm
--,os.glec
--,m.biggroup
--,os.priceg
)
,bgt AS (
SELECT
bill_dba
,ship_dba
,dsm
,sum(sales_usd) sales
,sum(pounds) pounds
--string_agg(distinct mold,', ')
FROM
rlarp.osm_stack
WHERE
version = 'Budget'
AND oseas = '2024'
GROUP BY
bill_dba
,ship_dba
,dsm
)
,agg AS (
SELECT
COALESCE(act.bill_dba,TRIM(bgt.bill_dba)) bill_dba
,COALESCE(act.ship_dba,TRIM(bgt.ship_dba)) ship_dba
,COALESCE(act.dsm ,TRIM(bgt.dsm )) dsm
,COALESCE(SUM(bgt.pounds ),0) "Budget 2024"
,COALESCE(SUM(act."Actual 2023"),0) "Actual 2023"
,COALESCE(SUM(act."Actual 2024"),0) "Actual 2024"
,COALESCE(SUM(act."Open Ord" ),0) "Open Ord"
--,COALESCE(SUM(act."Quotes" ),0) "Quotes"
FROM
act
FULL OUTER JOIN bgt ON
TRIM(bgt.bill_dba) = act.bill_dba
AND TRIM(bgt.ship_dba) = act.ship_dba
AND TRIM(bgt.dsm ) = act.dsm
GROUP BY
COALESCE(act.bill_dba,TRIM(bgt.bill_dba))
,COALESCE(act.ship_dba,TRIM(bgt.ship_dba))
,COALESCE(act.dsm ,TRIM(bgt.dsm ))
)
SELECT * FROM agg;
------------------------------------------sales walk-------------------------------------------------------
CREATE OR REPLACE VIEW rlarp.cust_review AS
SELECT
agg.bill_dba
,agg.ship_dba
,agg.dsm
,agg."Budget 2024" budget_2024
,agg."Actual 2023" shipments_2023
,agg."Actual 2024" shipments_2024
,agg."Open Ord" open_orders_2024
--,"Quotes" quotes
,COALESCE(a.newords,0) newords
,COALESCE(a.newuom,'') newuom
FROM
rlarp.cust_review_agg agg
LEFT OUTER JOIN rlarp.customer_review a ON
a.ship_cust = agg.ship_dba
WHERE
"Budget 2024" <> 0
OR "Actual 2023" <> 0
OR ("Actual 2024") <> 0
OR ("Open Ord") <> 0
--OR ("Quotes") <> 0
ORDER BY
dsm
--,"Budget 2024" + "Actual 2024" + "Actual 2023" + "Open Ord" + "Quotes" desc;
,"Budget 2024" + "Actual 2024" + "Actual 2023" + "Open Ord" desc;
GRANT SELECT ON rlarp.cust_review TO PUBLIC;
--,biggroup

12
sql/write_note.sql Normal file
View File

@ -0,0 +1,12 @@
MERGE INTO
rlarp.customer_review w
USING
( SELECT $1 bill_cust, $2 ship_cust, $3::numeric expected, $4 expecteduom) as i ON
i.ship_cust = w.ship_cust
AND i.bill_cust = w.bill_cust
WHEN MATCHED THEN UPDATE SET
newords = i.expected
,newuom = i.expecteduom
WHEN NOT MATCHED THEN
INSERT (bill_cust, ship_cust, newords, newuom)
VALUES (bill_cust,i.ship_cust, i.expected, i.expecteduom)