From fb43e4f3e503584000a58c42f56cbf1cee48e8c5 Mon Sep 17 00:00:00 2001 From: Ethan Strominger Date: Tue, 10 Sep 2024 13:29:04 -0400 Subject: [PATCH 01/26] Modify schema.prisma Co-authored-by: AdamFinkle --- heat-stack/package-lock.json | 80 ++++++++++--------- heat-stack/package.json | 12 +-- .../migration.sql | 49 ++---------- heat-stack/prisma/schema.prisma | 7 ++ 4 files changed, 62 insertions(+), 86 deletions(-) rename heat-stack/prisma/migrations/{20230914194400_init => 20240910171848_oil3}/migration.sql (59%) diff --git a/heat-stack/package-lock.json b/heat-stack/package-lock.json index 9ad49ee9..6cf192c9 100644 --- a/heat-stack/package-lock.json +++ b/heat-stack/package-lock.json @@ -15,7 +15,7 @@ "@epic-web/totp": "^1.1.2", "@nasa-gcn/remix-seo": "^2.0.1", "@paralleldrive/cuid2": "^2.2.2", - "@prisma/client": "^5.17.0", + "@prisma/client": "^5.19.1", "@radix-ui/react-checkbox": "^1.1.1", "@radix-ui/react-dropdown-menu": "^2.1.1", "@radix-ui/react-label": "^2.1.0", @@ -54,7 +54,6 @@ "lru-cache": "^11.0.0", "lucide-react": "^0.428.0", "morgan": "^1.10.0", - "prisma": "^5.17.0", "pyodide": "0.24.1", "qrcode": "^1.5.3", "react": "^18.3.1", @@ -116,6 +115,7 @@ "prettier": "^3.3.3", "prettier-plugin-sql": "^0.18.1", "prettier-plugin-tailwindcss": "^0.6.5", + "prisma": "^5.19.1", "remix-flat-routes": "^0.6.5", "tsx": "^4.16.2", "typescript": "^5.5.3", @@ -2578,11 +2578,10 @@ } }, "node_modules/@prisma/client": { - "version": "5.17.0", - "resolved": "https://registry.npmjs.org/@prisma/client/-/client-5.17.0.tgz", - "integrity": "sha512-N2tnyKayT0Zf7mHjwEyE8iG7FwTmXDHFZ1GnNhQp0pJUObsuel4ZZ1XwfuAYkq5mRIiC/Kot0kt0tGCfLJ70Jw==", + "version": "5.19.1", + "resolved": "https://registry.npmjs.org/@prisma/client/-/client-5.19.1.tgz", + "integrity": "sha512-x30GFguInsgt+4z5I4WbkZP2CGpotJMUXy+Gl/aaUjHn2o1DnLYNTA+q9XdYmAQZM8fIIkvUiA2NpgosM3fneg==", "hasInstallScript": true, - "license": "Apache-2.0", "engines": { "node": ">=16.13" }, @@ -2596,48 +2595,48 @@ } }, "node_modules/@prisma/debug": { - "version": "5.17.0", - "resolved": "https://registry.npmjs.org/@prisma/debug/-/debug-5.17.0.tgz", - "integrity": "sha512-l7+AteR3P8FXiYyo496zkuoiJ5r9jLQEdUuxIxNCN1ud8rdbH3GTxm+f+dCyaSv9l9WY+29L9czaVRXz9mULfg==", - "license": "Apache-2.0" + "version": "5.19.1", + "resolved": "https://registry.npmjs.org/@prisma/debug/-/debug-5.19.1.tgz", + "integrity": "sha512-lAG6A6QnG2AskAukIEucYJZxxcSqKsMK74ZFVfCTOM/7UiyJQi48v6TQ47d6qKG3LbMslqOvnTX25dj/qvclGg==", + "dev": true }, "node_modules/@prisma/engines": { - "version": "5.17.0", - "resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-5.17.0.tgz", - "integrity": "sha512-+r+Nf+JP210Jur+/X8SIPLtz+uW9YA4QO5IXA+KcSOBe/shT47bCcRMTYCbOESw3FFYFTwe7vU6KTWHKPiwvtg==", + "version": "5.19.1", + "resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-5.19.1.tgz", + "integrity": "sha512-kR/PoxZDrfUmbbXqqb8SlBBgCjvGaJYMCOe189PEYzq9rKqitQ2fvT/VJ8PDSe8tTNxhc2KzsCfCAL+Iwm/7Cg==", + "dev": true, "hasInstallScript": true, - "license": "Apache-2.0", "dependencies": { - "@prisma/debug": "5.17.0", - "@prisma/engines-version": "5.17.0-31.393aa359c9ad4a4bb28630fb5613f9c281cde053", - "@prisma/fetch-engine": "5.17.0", - "@prisma/get-platform": "5.17.0" + "@prisma/debug": "5.19.1", + "@prisma/engines-version": "5.19.1-2.69d742ee20b815d88e17e54db4a2a7a3b30324e3", + "@prisma/fetch-engine": "5.19.1", + "@prisma/get-platform": "5.19.1" } }, "node_modules/@prisma/engines-version": { - "version": "5.17.0-31.393aa359c9ad4a4bb28630fb5613f9c281cde053", - "resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-5.17.0-31.393aa359c9ad4a4bb28630fb5613f9c281cde053.tgz", - "integrity": "sha512-tUuxZZysZDcrk5oaNOdrBnnkoTtmNQPkzINFDjz7eG6vcs9AVDmA/F6K5Plsb2aQc/l5M2EnFqn3htng9FA4hg==", - "license": "Apache-2.0" + "version": "5.19.1-2.69d742ee20b815d88e17e54db4a2a7a3b30324e3", + "resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-5.19.1-2.69d742ee20b815d88e17e54db4a2a7a3b30324e3.tgz", + "integrity": "sha512-xR6rt+z5LnNqTP5BBc+8+ySgf4WNMimOKXRn6xfNRDSpHvbOEmd7+qAOmzCrddEc4Cp8nFC0txU14dstjH7FXA==", + "dev": true }, "node_modules/@prisma/fetch-engine": { - "version": "5.17.0", - "resolved": "https://registry.npmjs.org/@prisma/fetch-engine/-/fetch-engine-5.17.0.tgz", - "integrity": "sha512-ESxiOaHuC488ilLPnrv/tM2KrPhQB5TRris/IeIV4ZvUuKeaicCl4Xj/JCQeG9IlxqOgf1cCg5h5vAzlewN91Q==", - "license": "Apache-2.0", + "version": "5.19.1", + "resolved": "https://registry.npmjs.org/@prisma/fetch-engine/-/fetch-engine-5.19.1.tgz", + "integrity": "sha512-pCq74rtlOVJfn4pLmdJj+eI4P7w2dugOnnTXpRilP/6n5b2aZiA4ulJlE0ddCbTPkfHmOL9BfaRgA8o+1rfdHw==", + "dev": true, "dependencies": { - "@prisma/debug": "5.17.0", - "@prisma/engines-version": "5.17.0-31.393aa359c9ad4a4bb28630fb5613f9c281cde053", - "@prisma/get-platform": "5.17.0" + "@prisma/debug": "5.19.1", + "@prisma/engines-version": "5.19.1-2.69d742ee20b815d88e17e54db4a2a7a3b30324e3", + "@prisma/get-platform": "5.19.1" } }, "node_modules/@prisma/get-platform": { - "version": "5.17.0", - "resolved": "https://registry.npmjs.org/@prisma/get-platform/-/get-platform-5.17.0.tgz", - "integrity": "sha512-UlDgbRozCP1rfJ5Tlkf3Cnftb6srGrEQ4Nm3og+1Se2gWmCZ0hmPIi+tQikGDUVLlvOWx3Gyi9LzgRP+HTXV9w==", - "license": "Apache-2.0", + "version": "5.19.1", + "resolved": "https://registry.npmjs.org/@prisma/get-platform/-/get-platform-5.19.1.tgz", + "integrity": "sha512-sCeoJ+7yt0UjnR+AXZL7vXlg5eNxaFOwC23h0KvW1YIXUoa7+W2ZcAUhoEQBmJTW4GrFqCuZ8YSP0mkDa4k3Zg==", + "dev": true, "dependencies": { - "@prisma/debug": "5.17.0" + "@prisma/debug": "5.19.1" } }, "node_modules/@prisma/instrumentation": { @@ -17248,19 +17247,22 @@ } }, "node_modules/prisma": { - "version": "5.17.0", - "resolved": "https://registry.npmjs.org/prisma/-/prisma-5.17.0.tgz", - "integrity": "sha512-m4UWkN5lBE6yevqeOxEvmepnL5cNPEjzMw2IqDB59AcEV6w7D8vGljDLd1gPFH+W6gUxw9x7/RmN5dCS/WTPxA==", + "version": "5.19.1", + "resolved": "https://registry.npmjs.org/prisma/-/prisma-5.19.1.tgz", + "integrity": "sha512-c5K9MiDaa+VAAyh1OiYk76PXOme9s3E992D7kvvIOhCrNsBQfy2mP2QAQtX0WNj140IgG++12kwZpYB9iIydNQ==", + "dev": true, "hasInstallScript": true, - "license": "Apache-2.0", "dependencies": { - "@prisma/engines": "5.17.0" + "@prisma/engines": "5.19.1" }, "bin": { "prisma": "build/index.js" }, "engines": { "node": ">=16.13" + }, + "optionalDependencies": { + "fsevents": "2.3.3" } }, "node_modules/prismjs": { diff --git a/heat-stack/package.json b/heat-stack/package.json index 4070435a..1e742388 100644 --- a/heat-stack/package.json +++ b/heat-stack/package.json @@ -8,6 +8,9 @@ "#app/*": "./app/*", "#tests/*": "./tests/*" }, + "prisma": { + "seed": "ts-node ./prisma/seed.ts" + }, "scripts": { "build": "run-s build:*", "build:icons": "tsx ./other/build-icons.ts", @@ -50,7 +53,7 @@ "@epic-web/totp": "^1.1.2", "@nasa-gcn/remix-seo": "^2.0.1", "@paralleldrive/cuid2": "^2.2.2", - "@prisma/client": "^5.17.0", + "@prisma/client": "^5.19.1", "@radix-ui/react-checkbox": "^1.1.1", "@radix-ui/react-dropdown-menu": "^2.1.1", "@radix-ui/react-label": "^2.1.0", @@ -86,10 +89,9 @@ "intl-parse-accept-language": "^1.0.0", "isbot": "^5.1.13", "litefs-js": "^1.1.2", - "lucide-react": "^0.428.0", "lru-cache": "^11.0.0", + "lucide-react": "^0.428.0", "morgan": "^1.10.0", - "prisma": "^5.17.0", "pyodide": "0.24.1", "qrcode": "^1.5.3", "react": "^18.3.1", @@ -151,6 +153,7 @@ "prettier": "^3.3.3", "prettier-plugin-sql": "^0.18.1", "prettier-plugin-tailwindcss": "^0.6.5", + "prisma": "^5.19.1", "remix-flat-routes": "^0.6.5", "tsx": "^4.16.2", "typescript": "^5.5.3", @@ -163,8 +166,5 @@ "epic-stack": { "head": "b2f899fec54a76c1e0e863dadad6e9340af5ca1b", "date": "2024-08-15T23:19:44Z" - }, - "prisma": { - "seed": "tsx prisma/seed.ts" } } diff --git a/heat-stack/prisma/migrations/20230914194400_init/migration.sql b/heat-stack/prisma/migrations/20240910171848_oil3/migration.sql similarity index 59% rename from heat-stack/prisma/migrations/20230914194400_init/migration.sql rename to heat-stack/prisma/migrations/20240910171848_oil3/migration.sql index 6349954e..1fc4c90b 100644 --- a/heat-stack/prisma/migrations/20230914194400_init/migration.sql +++ b/heat-stack/prisma/migrations/20240910171848_oil3/migration.sql @@ -105,6 +105,14 @@ CREATE TABLE "Connection" ( CONSTRAINT "Connection_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE ); +-- CreateTable +CREATE TABLE "OilPropaneBillingRecordInput" ( + "id" TEXT NOT NULL PRIMARY KEY, + "period_end_date" DATETIME NOT NULL, + "gallons" REAL NOT NULL, + "inclusion_override" TEXT NOT NULL +); + -- CreateTable CREATE TABLE "_PermissionToRole" ( "A" TEXT NOT NULL, @@ -168,44 +176,3 @@ CREATE UNIQUE INDEX "_RoleToUser_AB_unique" ON "_RoleToUser"("A", "B"); -- CreateIndex CREATE INDEX "_RoleToUser_B_index" ON "_RoleToUser"("B"); - ---------------------------------- Manual Seeding -------------------------- --- Hey there, Kent here! This is how you can reliably seed your database with --- some data. You edit the migration.sql file and that will handle it for you. - -INSERT INTO Permission VALUES('clnf2zvli0000pcou3zzzzome','create','user','own','',1696625465526,1696625465526); -INSERT INTO Permission VALUES('clnf2zvll0001pcouly1310ku','create','user','any','',1696625465529,1696625465529); -INSERT INTO Permission VALUES('clnf2zvll0002pcouka7348re','read','user','own','',1696625465530,1696625465530); -INSERT INTO Permission VALUES('clnf2zvlm0003pcouea4dee51','read','user','any','',1696625465530,1696625465530); -INSERT INTO Permission VALUES('clnf2zvlm0004pcou2guvolx5','update','user','own','',1696625465531,1696625465531); -INSERT INTO Permission VALUES('clnf2zvln0005pcoun78ps5ap','update','user','any','',1696625465531,1696625465531); -INSERT INTO Permission VALUES('clnf2zvlo0006pcouyoptc5jp','delete','user','own','',1696625465532,1696625465532); -INSERT INTO Permission VALUES('clnf2zvlo0007pcouw1yzoyam','delete','user','any','',1696625465533,1696625465533); -INSERT INTO Permission VALUES('clnf2zvlp0008pcou9r0fhbm8','create','note','own','',1696625465533,1696625465533); -INSERT INTO Permission VALUES('clnf2zvlp0009pcouj3qib9q9','create','note','any','',1696625465534,1696625465534); -INSERT INTO Permission VALUES('clnf2zvlq000apcouxnspejs9','read','note','own','',1696625465535,1696625465535); -INSERT INTO Permission VALUES('clnf2zvlr000bpcouf4cg3x72','read','note','any','',1696625465535,1696625465535); -INSERT INTO Permission VALUES('clnf2zvlr000cpcouy1vp6oeg','update','note','own','',1696625465536,1696625465536); -INSERT INTO Permission VALUES('clnf2zvls000dpcouvzwjjzrq','update','note','any','',1696625465536,1696625465536); -INSERT INTO Permission VALUES('clnf2zvls000epcou4ts5ui8f','delete','note','own','',1696625465537,1696625465537); -INSERT INTO Permission VALUES('clnf2zvlt000fpcouk29jbmxn','delete','note','any','',1696625465538,1696625465538); - -INSERT INTO Role VALUES('clnf2zvlw000gpcour6dyyuh6','admin','',1696625465540,1696625465540); -INSERT INTO Role VALUES('clnf2zvlx000hpcou5dfrbegs','user','',1696625465542,1696625465542); - -INSERT INTO _PermissionToRole VALUES('clnf2zvll0001pcouly1310ku','clnf2zvlw000gpcour6dyyuh6'); -INSERT INTO _PermissionToRole VALUES('clnf2zvlm0003pcouea4dee51','clnf2zvlw000gpcour6dyyuh6'); -INSERT INTO _PermissionToRole VALUES('clnf2zvln0005pcoun78ps5ap','clnf2zvlw000gpcour6dyyuh6'); -INSERT INTO _PermissionToRole VALUES('clnf2zvlo0007pcouw1yzoyam','clnf2zvlw000gpcour6dyyuh6'); -INSERT INTO _PermissionToRole VALUES('clnf2zvlp0009pcouj3qib9q9','clnf2zvlw000gpcour6dyyuh6'); -INSERT INTO _PermissionToRole VALUES('clnf2zvlr000bpcouf4cg3x72','clnf2zvlw000gpcour6dyyuh6'); -INSERT INTO _PermissionToRole VALUES('clnf2zvls000dpcouvzwjjzrq','clnf2zvlw000gpcour6dyyuh6'); -INSERT INTO _PermissionToRole VALUES('clnf2zvlt000fpcouk29jbmxn','clnf2zvlw000gpcour6dyyuh6'); -INSERT INTO _PermissionToRole VALUES('clnf2zvli0000pcou3zzzzome','clnf2zvlx000hpcou5dfrbegs'); -INSERT INTO _PermissionToRole VALUES('clnf2zvll0002pcouka7348re','clnf2zvlx000hpcou5dfrbegs'); -INSERT INTO _PermissionToRole VALUES('clnf2zvlm0004pcou2guvolx5','clnf2zvlx000hpcou5dfrbegs'); -INSERT INTO _PermissionToRole VALUES('clnf2zvlo0006pcouyoptc5jp','clnf2zvlx000hpcou5dfrbegs'); -INSERT INTO _PermissionToRole VALUES('clnf2zvlp0008pcou9r0fhbm8','clnf2zvlx000hpcou5dfrbegs'); -INSERT INTO _PermissionToRole VALUES('clnf2zvlq000apcouxnspejs9','clnf2zvlx000hpcou5dfrbegs'); -INSERT INTO _PermissionToRole VALUES('clnf2zvlr000cpcouy1vp6oeg','clnf2zvlx000hpcou5dfrbegs'); -INSERT INTO _PermissionToRole VALUES('clnf2zvls000epcou4ts5ui8f','clnf2zvlx000hpcou5dfrbegs'); \ No newline at end of file diff --git a/heat-stack/prisma/schema.prisma b/heat-stack/prisma/schema.prisma index 975d2431..5667b96c 100644 --- a/heat-stack/prisma/schema.prisma +++ b/heat-stack/prisma/schema.prisma @@ -167,3 +167,10 @@ model Connection { @@unique([providerName, providerId]) } + +model OilPropaneBillingRecordInput { + id String @id @default(cuid()) + period_end_date DateTime + gallons Float + inclusion_override String +} \ No newline at end of file From 149f1d4d917a05959965bab1507e96405b7c4202 Mon Sep 17 00:00:00 2001 From: Ethan-Strominger <32078396+ethanstrominger@users.noreply.github.com> Date: Thu, 19 Sep 2024 20:15:20 +0000 Subject: [PATCH 02/26] Created home and case entries Co-authored-by: AdamFinkle --- heat-stack/prisma/README.md | 19 ++ .../20240910171848_oil3/migration.sql | 178 ------------------ .../prisma/migrations/migration_lock.toml | 3 - heat-stack/prisma/schema.prisma | 29 ++- 4 files changed, 42 insertions(+), 187 deletions(-) create mode 100644 heat-stack/prisma/README.md delete mode 100644 heat-stack/prisma/migrations/20240910171848_oil3/migration.sql delete mode 100644 heat-stack/prisma/migrations/migration_lock.toml diff --git a/heat-stack/prisma/README.md b/heat-stack/prisma/README.md new file mode 100644 index 00000000..666dbaf0 --- /dev/null +++ b/heat-stack/prisma/README.md @@ -0,0 +1,19 @@ +# To Change the Schema +First, edit schema.prisma. + +Then, migrate the database by changing to this directory and type: +``` +npx prisma migrate dev --name NAME +``` +where NAME is your choice of migration name. + +# To Generate the Database without Changing the Schema +First, generate the prisma client +``` +npx prisma generate +``` +Then, synchronize your schema with the database: +``` +npx prisma db push +``` + diff --git a/heat-stack/prisma/migrations/20240910171848_oil3/migration.sql b/heat-stack/prisma/migrations/20240910171848_oil3/migration.sql deleted file mode 100644 index 1fc4c90b..00000000 --- a/heat-stack/prisma/migrations/20240910171848_oil3/migration.sql +++ /dev/null @@ -1,178 +0,0 @@ --- CreateTable -CREATE TABLE "User" ( - "id" TEXT NOT NULL PRIMARY KEY, - "email" TEXT NOT NULL, - "username" TEXT NOT NULL, - "name" TEXT, - "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" DATETIME NOT NULL -); - --- CreateTable -CREATE TABLE "Note" ( - "id" TEXT NOT NULL PRIMARY KEY, - "title" TEXT NOT NULL, - "content" TEXT NOT NULL, - "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" DATETIME NOT NULL, - "ownerId" TEXT NOT NULL, - CONSTRAINT "Note_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE -); - --- CreateTable -CREATE TABLE "NoteImage" ( - "id" TEXT NOT NULL PRIMARY KEY, - "altText" TEXT, - "contentType" TEXT NOT NULL, - "blob" BLOB NOT NULL, - "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" DATETIME NOT NULL, - "noteId" TEXT NOT NULL, - CONSTRAINT "NoteImage_noteId_fkey" FOREIGN KEY ("noteId") REFERENCES "Note" ("id") ON DELETE CASCADE ON UPDATE CASCADE -); - --- CreateTable -CREATE TABLE "UserImage" ( - "id" TEXT NOT NULL PRIMARY KEY, - "altText" TEXT, - "contentType" TEXT NOT NULL, - "blob" BLOB NOT NULL, - "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" DATETIME NOT NULL, - "userId" TEXT NOT NULL, - CONSTRAINT "UserImage_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE -); - --- CreateTable -CREATE TABLE "Password" ( - "hash" TEXT NOT NULL, - "userId" TEXT NOT NULL, - CONSTRAINT "Password_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE -); - --- CreateTable -CREATE TABLE "Session" ( - "id" TEXT NOT NULL PRIMARY KEY, - "expirationDate" DATETIME NOT NULL, - "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" DATETIME NOT NULL, - "userId" TEXT NOT NULL, - CONSTRAINT "Session_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE -); - --- CreateTable -CREATE TABLE "Permission" ( - "id" TEXT NOT NULL PRIMARY KEY, - "action" TEXT NOT NULL, - "entity" TEXT NOT NULL, - "access" TEXT NOT NULL, - "description" TEXT NOT NULL DEFAULT '', - "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" DATETIME NOT NULL -); - --- CreateTable -CREATE TABLE "Role" ( - "id" TEXT NOT NULL PRIMARY KEY, - "name" TEXT NOT NULL, - "description" TEXT NOT NULL DEFAULT '', - "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" DATETIME NOT NULL -); - --- CreateTable -CREATE TABLE "Verification" ( - "id" TEXT NOT NULL PRIMARY KEY, - "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - "type" TEXT NOT NULL, - "target" TEXT NOT NULL, - "secret" TEXT NOT NULL, - "algorithm" TEXT NOT NULL, - "digits" INTEGER NOT NULL, - "period" INTEGER NOT NULL, - "charSet" TEXT NOT NULL, - "expiresAt" DATETIME -); - --- CreateTable -CREATE TABLE "Connection" ( - "id" TEXT NOT NULL PRIMARY KEY, - "providerName" TEXT NOT NULL, - "providerId" TEXT NOT NULL, - "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" DATETIME NOT NULL, - "userId" TEXT NOT NULL, - CONSTRAINT "Connection_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE -); - --- CreateTable -CREATE TABLE "OilPropaneBillingRecordInput" ( - "id" TEXT NOT NULL PRIMARY KEY, - "period_end_date" DATETIME NOT NULL, - "gallons" REAL NOT NULL, - "inclusion_override" TEXT NOT NULL -); - --- CreateTable -CREATE TABLE "_PermissionToRole" ( - "A" TEXT NOT NULL, - "B" TEXT NOT NULL, - CONSTRAINT "_PermissionToRole_A_fkey" FOREIGN KEY ("A") REFERENCES "Permission" ("id") ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT "_PermissionToRole_B_fkey" FOREIGN KEY ("B") REFERENCES "Role" ("id") ON DELETE CASCADE ON UPDATE CASCADE -); - --- CreateTable -CREATE TABLE "_RoleToUser" ( - "A" TEXT NOT NULL, - "B" TEXT NOT NULL, - CONSTRAINT "_RoleToUser_A_fkey" FOREIGN KEY ("A") REFERENCES "Role" ("id") ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT "_RoleToUser_B_fkey" FOREIGN KEY ("B") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE -); - --- CreateIndex -CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); - --- CreateIndex -CREATE UNIQUE INDEX "User_username_key" ON "User"("username"); - --- CreateIndex -CREATE INDEX "Note_ownerId_idx" ON "Note"("ownerId"); - --- CreateIndex -CREATE INDEX "Note_ownerId_updatedAt_idx" ON "Note"("ownerId", "updatedAt"); - --- CreateIndex -CREATE INDEX "NoteImage_noteId_idx" ON "NoteImage"("noteId"); - --- CreateIndex -CREATE UNIQUE INDEX "UserImage_userId_key" ON "UserImage"("userId"); - --- CreateIndex -CREATE UNIQUE INDEX "Password_userId_key" ON "Password"("userId"); - --- CreateIndex -CREATE INDEX "Session_userId_idx" ON "Session"("userId"); - --- CreateIndex -CREATE UNIQUE INDEX "Permission_action_entity_access_key" ON "Permission"("action", "entity", "access"); - --- CreateIndex -CREATE UNIQUE INDEX "Role_name_key" ON "Role"("name"); - --- CreateIndex -CREATE UNIQUE INDEX "Verification_target_type_key" ON "Verification"("target", "type"); - --- CreateIndex -CREATE UNIQUE INDEX "Connection_providerName_providerId_key" ON "Connection"("providerName", "providerId"); - --- CreateIndex -CREATE UNIQUE INDEX "_PermissionToRole_AB_unique" ON "_PermissionToRole"("A", "B"); - --- CreateIndex -CREATE INDEX "_PermissionToRole_B_index" ON "_PermissionToRole"("B"); - --- CreateIndex -CREATE UNIQUE INDEX "_RoleToUser_AB_unique" ON "_RoleToUser"("A", "B"); - --- CreateIndex -CREATE INDEX "_RoleToUser_B_index" ON "_RoleToUser"("B"); diff --git a/heat-stack/prisma/migrations/migration_lock.toml b/heat-stack/prisma/migrations/migration_lock.toml deleted file mode 100644 index e5e5c470..00000000 --- a/heat-stack/prisma/migrations/migration_lock.toml +++ /dev/null @@ -1,3 +0,0 @@ -# Please do not edit this file manually -# It should be added in your version-control system (i.e. Git) -provider = "sqlite" \ No newline at end of file diff --git a/heat-stack/prisma/schema.prisma b/heat-stack/prisma/schema.prisma index 5667b96c..f74ba1e7 100644 --- a/heat-stack/prisma/schema.prisma +++ b/heat-stack/prisma/schema.prisma @@ -168,9 +168,26 @@ model Connection { @@unique([providerName, providerId]) } -model OilPropaneBillingRecordInput { - id String @id @default(cuid()) - period_end_date DateTime - gallons Float - inclusion_override String -} \ No newline at end of file +model Home { + id String @id @default(cuid()) + name String + address String + livingArea Float + Case Case[] +} + +model Case { + id String @id @default(cuid()) + // homeId is a foreign key to a Home object, the primary (referenced) key of which is id + home Home @relation(fields: [homeId], references: [id], onDelete: Cascade, onUpdate: Cascade) + homeId String + fuelType String + designTemperatureOverride Boolean + heatingSystemEfficiency Int + thermostatSetPoint Int + setbackTemperature Int + setbackHoursPerDay Int + numberOfOccupants Int + estimatedWaterHeatingEfficiency Int + standByLosses Int +} From 45ff6fb2914c676d6fe27e5d9424865ce2f71c39 Mon Sep 17 00:00:00 2001 From: Ethan-Strominger <32078396+ethanstrominger@users.noreply.github.com> Date: Fri, 20 Sep 2024 15:57:25 +0000 Subject: [PATCH 03/26] Add file table Co-authored-by: AdamFinkle --- heat-stack/prisma/README.md | 11 +- .../20240920154214_file/migration.sql | 205 ++++++++++++++++++ .../prisma/migrations/migration_lock.toml | 3 + heat-stack/prisma/schema.prisma | 16 +- 4 files changed, 225 insertions(+), 10 deletions(-) create mode 100644 heat-stack/prisma/migrations/20240920154214_file/migration.sql create mode 100644 heat-stack/prisma/migrations/migration_lock.toml diff --git a/heat-stack/prisma/README.md b/heat-stack/prisma/README.md index 666dbaf0..ec3bc8b4 100644 --- a/heat-stack/prisma/README.md +++ b/heat-stack/prisma/README.md @@ -8,12 +8,5 @@ npx prisma migrate dev --name NAME where NAME is your choice of migration name. # To Generate the Database without Changing the Schema -First, generate the prisma client -``` -npx prisma generate -``` -Then, synchronize your schema with the database: -``` -npx prisma db push -``` - +TODO: Figure this out +``` \ No newline at end of file diff --git a/heat-stack/prisma/migrations/20240920154214_file/migration.sql b/heat-stack/prisma/migrations/20240920154214_file/migration.sql new file mode 100644 index 00000000..df0491db --- /dev/null +++ b/heat-stack/prisma/migrations/20240920154214_file/migration.sql @@ -0,0 +1,205 @@ +-- CreateTable +CREATE TABLE "User" ( + "id" TEXT NOT NULL PRIMARY KEY, + "email" TEXT NOT NULL, + "username" TEXT NOT NULL, + "name" TEXT, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL +); + +-- CreateTable +CREATE TABLE "Note" ( + "id" TEXT NOT NULL PRIMARY KEY, + "title" TEXT NOT NULL, + "content" TEXT NOT NULL, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL, + "ownerId" TEXT NOT NULL, + CONSTRAINT "Note_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); + +-- CreateTable +CREATE TABLE "NoteImage" ( + "id" TEXT NOT NULL PRIMARY KEY, + "altText" TEXT, + "contentType" TEXT NOT NULL, + "blob" BLOB NOT NULL, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL, + "noteId" TEXT NOT NULL, + CONSTRAINT "NoteImage_noteId_fkey" FOREIGN KEY ("noteId") REFERENCES "Note" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); + +-- CreateTable +CREATE TABLE "UserImage" ( + "id" TEXT NOT NULL PRIMARY KEY, + "altText" TEXT, + "contentType" TEXT NOT NULL, + "blob" BLOB NOT NULL, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL, + "userId" TEXT NOT NULL, + CONSTRAINT "UserImage_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); + +-- CreateTable +CREATE TABLE "Password" ( + "hash" TEXT NOT NULL, + "userId" TEXT NOT NULL, + CONSTRAINT "Password_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); + +-- CreateTable +CREATE TABLE "Session" ( + "id" TEXT NOT NULL PRIMARY KEY, + "expirationDate" DATETIME NOT NULL, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL, + "userId" TEXT NOT NULL, + CONSTRAINT "Session_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); + +-- CreateTable +CREATE TABLE "Permission" ( + "id" TEXT NOT NULL PRIMARY KEY, + "action" TEXT NOT NULL, + "entity" TEXT NOT NULL, + "access" TEXT NOT NULL, + "description" TEXT NOT NULL DEFAULT '', + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL +); + +-- CreateTable +CREATE TABLE "Role" ( + "id" TEXT NOT NULL PRIMARY KEY, + "name" TEXT NOT NULL, + "description" TEXT NOT NULL DEFAULT '', + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL +); + +-- CreateTable +CREATE TABLE "Verification" ( + "id" TEXT NOT NULL PRIMARY KEY, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "type" TEXT NOT NULL, + "target" TEXT NOT NULL, + "secret" TEXT NOT NULL, + "algorithm" TEXT NOT NULL, + "digits" INTEGER NOT NULL, + "period" INTEGER NOT NULL, + "charSet" TEXT NOT NULL, + "expiresAt" DATETIME +); + +-- CreateTable +CREATE TABLE "Connection" ( + "id" TEXT NOT NULL PRIMARY KEY, + "providerName" TEXT NOT NULL, + "providerId" TEXT NOT NULL, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL, + "userId" TEXT NOT NULL, + CONSTRAINT "Connection_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); + +-- CreateTable +CREATE TABLE "Home" ( + "id" TEXT NOT NULL PRIMARY KEY, + "name" TEXT NOT NULL, + "address" TEXT NOT NULL, + "livingArea" REAL NOT NULL +); + +-- CreateTable +CREATE TABLE "Case" ( + "id" TEXT NOT NULL PRIMARY KEY, + "homeId" TEXT NOT NULL, + "fuelType" TEXT NOT NULL, + "designTemperatureOverride" BOOLEAN NOT NULL, + "heatingSystemEfficiency" INTEGER NOT NULL, + "thermostatSetPoint" INTEGER NOT NULL, + "setbackTemperature" INTEGER NOT NULL, + "setbackHoursPerDay" INTEGER NOT NULL, + "numberOfOccupants" INTEGER NOT NULL, + "estimatedWaterHeatingEfficiency" INTEGER NOT NULL, + "standByLosses" INTEGER NOT NULL, + CONSTRAINT "Case_homeId_fkey" FOREIGN KEY ("homeId") REFERENCES "Home" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); + +-- CreateTable +CREATE TABLE "File" ( + "id" TEXT NOT NULL PRIMARY KEY, + "homeId" TEXT NOT NULL, + "caseId" TEXT NOT NULL, + "filePath" TEXT NOT NULL, + "description" TEXT NOT NULL, + CONSTRAINT "File_homeId_fkey" FOREIGN KEY ("homeId") REFERENCES "Home" ("id") ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT "File_caseId_fkey" FOREIGN KEY ("caseId") REFERENCES "Case" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); + +-- CreateTable +CREATE TABLE "_PermissionToRole" ( + "A" TEXT NOT NULL, + "B" TEXT NOT NULL, + CONSTRAINT "_PermissionToRole_A_fkey" FOREIGN KEY ("A") REFERENCES "Permission" ("id") ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT "_PermissionToRole_B_fkey" FOREIGN KEY ("B") REFERENCES "Role" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); + +-- CreateTable +CREATE TABLE "_RoleToUser" ( + "A" TEXT NOT NULL, + "B" TEXT NOT NULL, + CONSTRAINT "_RoleToUser_A_fkey" FOREIGN KEY ("A") REFERENCES "Role" ("id") ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT "_RoleToUser_B_fkey" FOREIGN KEY ("B") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); + +-- CreateIndex +CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); + +-- CreateIndex +CREATE UNIQUE INDEX "User_username_key" ON "User"("username"); + +-- CreateIndex +CREATE INDEX "Note_ownerId_idx" ON "Note"("ownerId"); + +-- CreateIndex +CREATE INDEX "Note_ownerId_updatedAt_idx" ON "Note"("ownerId", "updatedAt"); + +-- CreateIndex +CREATE INDEX "NoteImage_noteId_idx" ON "NoteImage"("noteId"); + +-- CreateIndex +CREATE UNIQUE INDEX "UserImage_userId_key" ON "UserImage"("userId"); + +-- CreateIndex +CREATE UNIQUE INDEX "Password_userId_key" ON "Password"("userId"); + +-- CreateIndex +CREATE INDEX "Session_userId_idx" ON "Session"("userId"); + +-- CreateIndex +CREATE UNIQUE INDEX "Permission_action_entity_access_key" ON "Permission"("action", "entity", "access"); + +-- CreateIndex +CREATE UNIQUE INDEX "Role_name_key" ON "Role"("name"); + +-- CreateIndex +CREATE UNIQUE INDEX "Verification_target_type_key" ON "Verification"("target", "type"); + +-- CreateIndex +CREATE UNIQUE INDEX "Connection_providerName_providerId_key" ON "Connection"("providerName", "providerId"); + +-- CreateIndex +CREATE UNIQUE INDEX "_PermissionToRole_AB_unique" ON "_PermissionToRole"("A", "B"); + +-- CreateIndex +CREATE INDEX "_PermissionToRole_B_index" ON "_PermissionToRole"("B"); + +-- CreateIndex +CREATE UNIQUE INDEX "_RoleToUser_AB_unique" ON "_RoleToUser"("A", "B"); + +-- CreateIndex +CREATE INDEX "_RoleToUser_B_index" ON "_RoleToUser"("B"); diff --git a/heat-stack/prisma/migrations/migration_lock.toml b/heat-stack/prisma/migrations/migration_lock.toml new file mode 100644 index 00000000..e5e5c470 --- /dev/null +++ b/heat-stack/prisma/migrations/migration_lock.toml @@ -0,0 +1,3 @@ +# Please do not edit this file manually +# It should be added in your version-control system (i.e. Git) +provider = "sqlite" \ No newline at end of file diff --git a/heat-stack/prisma/schema.prisma b/heat-stack/prisma/schema.prisma index f74ba1e7..31eb6df7 100644 --- a/heat-stack/prisma/schema.prisma +++ b/heat-stack/prisma/schema.prisma @@ -173,7 +173,8 @@ model Home { name String address String livingArea Float - Case Case[] + Case Case[] + File File[] } model Case { @@ -190,4 +191,17 @@ model Case { numberOfOccupants Int estimatedWaterHeatingEfficiency Int standByLosses Int + File File[] } + +model File { + id String @id @default(cuid()) + home Home @relation(fields: [homeId], references: [id], onDelete: Cascade, onUpdate: Cascade) + case Case @relation(fields: [caseId], references: [id], onDelete: Cascade, onUpdate: Cascade) + homeId String + caseId String + filePath String + description String + // TODO: Storing the File CLOB proved difficult; regardless, we may want to store it in a external storage and replace this field with a String URL +} + From 4a8a40c2f9f324c2c4de9873eefc9527631f228a Mon Sep 17 00:00:00 2001 From: Ethan-Strominger <32078396+ethanstrominger@users.noreply.github.com> Date: Mon, 23 Sep 2024 18:24:30 +0000 Subject: [PATCH 04/26] Created all tables related to Case Co-authored-by: AdamFinkle --- .../migration.sql | 17 +++++++++++++++++ heat-stack/prisma/schema.prisma | 17 ++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) rename heat-stack/prisma/migrations/{20240920154214_file => 20240923182238_case_model}/migration.sql (90%) diff --git a/heat-stack/prisma/migrations/20240920154214_file/migration.sql b/heat-stack/prisma/migrations/20240923182238_case_model/migration.sql similarity index 90% rename from heat-stack/prisma/migrations/20240920154214_file/migration.sql rename to heat-stack/prisma/migrations/20240923182238_case_model/migration.sql index df0491db..3bebd349 100644 --- a/heat-stack/prisma/migrations/20240920154214_file/migration.sql +++ b/heat-stack/prisma/migrations/20240923182238_case_model/migration.sql @@ -140,6 +140,23 @@ CREATE TABLE "File" ( CONSTRAINT "File_caseId_fkey" FOREIGN KEY ("caseId") REFERENCES "Case" ("id") ON DELETE CASCADE ON UPDATE CASCADE ); +-- CreateTable +CREATE TABLE "BillingPeriod" ( + "id" TEXT NOT NULL PRIMARY KEY, + "caseId" TEXT NOT NULL, + "periodStartDate" DATETIME NOT NULL, + "periodEndDate" DATETIME NOT NULL, + "usage" REAL NOT NULL, + "analysisTypeOverride" BOOLEAN NOT NULL, + "inclusionOverride" BOOLEAN NOT NULL, + "originalAnalysisType" INTEGER NOT NULL, + "analysisType" INTEGER NOT NULL, + "defaultInclusionByCalculation" BOOLEAN NOT NULL, + "eliminatedAsOutlier" BOOLEAN NOT NULL, + "wholeHomeHeatLossRate" REAL NOT NULL, + CONSTRAINT "BillingPeriod_caseId_fkey" FOREIGN KEY ("caseId") REFERENCES "Case" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); + -- CreateTable CREATE TABLE "_PermissionToRole" ( "A" TEXT NOT NULL, diff --git a/heat-stack/prisma/schema.prisma b/heat-stack/prisma/schema.prisma index 31eb6df7..851e14e8 100644 --- a/heat-stack/prisma/schema.prisma +++ b/heat-stack/prisma/schema.prisma @@ -192,6 +192,7 @@ model Case { estimatedWaterHeatingEfficiency Int standByLosses Int File File[] + BillingPeriod BillingPeriod[] } model File { @@ -202,6 +203,20 @@ model File { caseId String filePath String description String - // TODO: Storing the File CLOB proved difficult; regardless, we may want to store it in a external storage and replace this field with a String URL } +model BillingPeriod { + id String @id @default(cuid()) + case Case @relation(fields: [caseId], references: [id], onDelete: Cascade, onUpdate: Cascade) + caseId String + periodStartDate DateTime + periodEndDate DateTime + usage Float + analysisTypeOverride Boolean + inclusionOverride Boolean + originalAnalysisType Int + analysisType Int + defaultInclusionByCalculation Boolean + eliminatedAsOutlier Boolean + wholeHomeHeatLossRate Float +} From 9ad5606892dac920eb5e0bf06e38c57e5031f8aa Mon Sep 17 00:00:00 2001 From: Ethan-Strominger <32078396+ethanstrominger@users.noreply.github.com> Date: Tue, 24 Sep 2024 17:06:24 +0000 Subject: [PATCH 05/26] Add summary output and relationships Co-authored-by: AdamFinkle --- .../20240923182238_case_model/migration.sql | 222 ------------------ .../prisma/migrations/migration_lock.toml | 3 - heat-stack/prisma/schema.prisma | 21 +- 3 files changed, 20 insertions(+), 226 deletions(-) delete mode 100644 heat-stack/prisma/migrations/20240923182238_case_model/migration.sql delete mode 100644 heat-stack/prisma/migrations/migration_lock.toml diff --git a/heat-stack/prisma/migrations/20240923182238_case_model/migration.sql b/heat-stack/prisma/migrations/20240923182238_case_model/migration.sql deleted file mode 100644 index 3bebd349..00000000 --- a/heat-stack/prisma/migrations/20240923182238_case_model/migration.sql +++ /dev/null @@ -1,222 +0,0 @@ --- CreateTable -CREATE TABLE "User" ( - "id" TEXT NOT NULL PRIMARY KEY, - "email" TEXT NOT NULL, - "username" TEXT NOT NULL, - "name" TEXT, - "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" DATETIME NOT NULL -); - --- CreateTable -CREATE TABLE "Note" ( - "id" TEXT NOT NULL PRIMARY KEY, - "title" TEXT NOT NULL, - "content" TEXT NOT NULL, - "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" DATETIME NOT NULL, - "ownerId" TEXT NOT NULL, - CONSTRAINT "Note_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE -); - --- CreateTable -CREATE TABLE "NoteImage" ( - "id" TEXT NOT NULL PRIMARY KEY, - "altText" TEXT, - "contentType" TEXT NOT NULL, - "blob" BLOB NOT NULL, - "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" DATETIME NOT NULL, - "noteId" TEXT NOT NULL, - CONSTRAINT "NoteImage_noteId_fkey" FOREIGN KEY ("noteId") REFERENCES "Note" ("id") ON DELETE CASCADE ON UPDATE CASCADE -); - --- CreateTable -CREATE TABLE "UserImage" ( - "id" TEXT NOT NULL PRIMARY KEY, - "altText" TEXT, - "contentType" TEXT NOT NULL, - "blob" BLOB NOT NULL, - "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" DATETIME NOT NULL, - "userId" TEXT NOT NULL, - CONSTRAINT "UserImage_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE -); - --- CreateTable -CREATE TABLE "Password" ( - "hash" TEXT NOT NULL, - "userId" TEXT NOT NULL, - CONSTRAINT "Password_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE -); - --- CreateTable -CREATE TABLE "Session" ( - "id" TEXT NOT NULL PRIMARY KEY, - "expirationDate" DATETIME NOT NULL, - "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" DATETIME NOT NULL, - "userId" TEXT NOT NULL, - CONSTRAINT "Session_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE -); - --- CreateTable -CREATE TABLE "Permission" ( - "id" TEXT NOT NULL PRIMARY KEY, - "action" TEXT NOT NULL, - "entity" TEXT NOT NULL, - "access" TEXT NOT NULL, - "description" TEXT NOT NULL DEFAULT '', - "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" DATETIME NOT NULL -); - --- CreateTable -CREATE TABLE "Role" ( - "id" TEXT NOT NULL PRIMARY KEY, - "name" TEXT NOT NULL, - "description" TEXT NOT NULL DEFAULT '', - "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" DATETIME NOT NULL -); - --- CreateTable -CREATE TABLE "Verification" ( - "id" TEXT NOT NULL PRIMARY KEY, - "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - "type" TEXT NOT NULL, - "target" TEXT NOT NULL, - "secret" TEXT NOT NULL, - "algorithm" TEXT NOT NULL, - "digits" INTEGER NOT NULL, - "period" INTEGER NOT NULL, - "charSet" TEXT NOT NULL, - "expiresAt" DATETIME -); - --- CreateTable -CREATE TABLE "Connection" ( - "id" TEXT NOT NULL PRIMARY KEY, - "providerName" TEXT NOT NULL, - "providerId" TEXT NOT NULL, - "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" DATETIME NOT NULL, - "userId" TEXT NOT NULL, - CONSTRAINT "Connection_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE -); - --- CreateTable -CREATE TABLE "Home" ( - "id" TEXT NOT NULL PRIMARY KEY, - "name" TEXT NOT NULL, - "address" TEXT NOT NULL, - "livingArea" REAL NOT NULL -); - --- CreateTable -CREATE TABLE "Case" ( - "id" TEXT NOT NULL PRIMARY KEY, - "homeId" TEXT NOT NULL, - "fuelType" TEXT NOT NULL, - "designTemperatureOverride" BOOLEAN NOT NULL, - "heatingSystemEfficiency" INTEGER NOT NULL, - "thermostatSetPoint" INTEGER NOT NULL, - "setbackTemperature" INTEGER NOT NULL, - "setbackHoursPerDay" INTEGER NOT NULL, - "numberOfOccupants" INTEGER NOT NULL, - "estimatedWaterHeatingEfficiency" INTEGER NOT NULL, - "standByLosses" INTEGER NOT NULL, - CONSTRAINT "Case_homeId_fkey" FOREIGN KEY ("homeId") REFERENCES "Home" ("id") ON DELETE CASCADE ON UPDATE CASCADE -); - --- CreateTable -CREATE TABLE "File" ( - "id" TEXT NOT NULL PRIMARY KEY, - "homeId" TEXT NOT NULL, - "caseId" TEXT NOT NULL, - "filePath" TEXT NOT NULL, - "description" TEXT NOT NULL, - CONSTRAINT "File_homeId_fkey" FOREIGN KEY ("homeId") REFERENCES "Home" ("id") ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT "File_caseId_fkey" FOREIGN KEY ("caseId") REFERENCES "Case" ("id") ON DELETE CASCADE ON UPDATE CASCADE -); - --- CreateTable -CREATE TABLE "BillingPeriod" ( - "id" TEXT NOT NULL PRIMARY KEY, - "caseId" TEXT NOT NULL, - "periodStartDate" DATETIME NOT NULL, - "periodEndDate" DATETIME NOT NULL, - "usage" REAL NOT NULL, - "analysisTypeOverride" BOOLEAN NOT NULL, - "inclusionOverride" BOOLEAN NOT NULL, - "originalAnalysisType" INTEGER NOT NULL, - "analysisType" INTEGER NOT NULL, - "defaultInclusionByCalculation" BOOLEAN NOT NULL, - "eliminatedAsOutlier" BOOLEAN NOT NULL, - "wholeHomeHeatLossRate" REAL NOT NULL, - CONSTRAINT "BillingPeriod_caseId_fkey" FOREIGN KEY ("caseId") REFERENCES "Case" ("id") ON DELETE CASCADE ON UPDATE CASCADE -); - --- CreateTable -CREATE TABLE "_PermissionToRole" ( - "A" TEXT NOT NULL, - "B" TEXT NOT NULL, - CONSTRAINT "_PermissionToRole_A_fkey" FOREIGN KEY ("A") REFERENCES "Permission" ("id") ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT "_PermissionToRole_B_fkey" FOREIGN KEY ("B") REFERENCES "Role" ("id") ON DELETE CASCADE ON UPDATE CASCADE -); - --- CreateTable -CREATE TABLE "_RoleToUser" ( - "A" TEXT NOT NULL, - "B" TEXT NOT NULL, - CONSTRAINT "_RoleToUser_A_fkey" FOREIGN KEY ("A") REFERENCES "Role" ("id") ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT "_RoleToUser_B_fkey" FOREIGN KEY ("B") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE -); - --- CreateIndex -CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); - --- CreateIndex -CREATE UNIQUE INDEX "User_username_key" ON "User"("username"); - --- CreateIndex -CREATE INDEX "Note_ownerId_idx" ON "Note"("ownerId"); - --- CreateIndex -CREATE INDEX "Note_ownerId_updatedAt_idx" ON "Note"("ownerId", "updatedAt"); - --- CreateIndex -CREATE INDEX "NoteImage_noteId_idx" ON "NoteImage"("noteId"); - --- CreateIndex -CREATE UNIQUE INDEX "UserImage_userId_key" ON "UserImage"("userId"); - --- CreateIndex -CREATE UNIQUE INDEX "Password_userId_key" ON "Password"("userId"); - --- CreateIndex -CREATE INDEX "Session_userId_idx" ON "Session"("userId"); - --- CreateIndex -CREATE UNIQUE INDEX "Permission_action_entity_access_key" ON "Permission"("action", "entity", "access"); - --- CreateIndex -CREATE UNIQUE INDEX "Role_name_key" ON "Role"("name"); - --- CreateIndex -CREATE UNIQUE INDEX "Verification_target_type_key" ON "Verification"("target", "type"); - --- CreateIndex -CREATE UNIQUE INDEX "Connection_providerName_providerId_key" ON "Connection"("providerName", "providerId"); - --- CreateIndex -CREATE UNIQUE INDEX "_PermissionToRole_AB_unique" ON "_PermissionToRole"("A", "B"); - --- CreateIndex -CREATE INDEX "_PermissionToRole_B_index" ON "_PermissionToRole"("B"); - --- CreateIndex -CREATE UNIQUE INDEX "_RoleToUser_AB_unique" ON "_RoleToUser"("A", "B"); - --- CreateIndex -CREATE INDEX "_RoleToUser_B_index" ON "_RoleToUser"("B"); diff --git a/heat-stack/prisma/migrations/migration_lock.toml b/heat-stack/prisma/migrations/migration_lock.toml deleted file mode 100644 index e5e5c470..00000000 --- a/heat-stack/prisma/migrations/migration_lock.toml +++ /dev/null @@ -1,3 +0,0 @@ -# Please do not edit this file manually -# It should be added in your version-control system (i.e. Git) -provider = "sqlite" \ No newline at end of file diff --git a/heat-stack/prisma/schema.prisma b/heat-stack/prisma/schema.prisma index 851e14e8..b4f2a8e3 100644 --- a/heat-stack/prisma/schema.prisma +++ b/heat-stack/prisma/schema.prisma @@ -179,9 +179,10 @@ model Home { model Case { id String @id @default(cuid()) - // homeId is a foreign key to a Home object, the primary (referenced) key of which is id home Home @relation(fields: [homeId], references: [id], onDelete: Cascade, onUpdate: Cascade) + summaryOutput SummaryOutput[] // There can be only one summaryOutput, but attempting anything else yielded an error. homeId String + summaryOutputId String @unique fuelType String designTemperatureOverride Boolean heatingSystemEfficiency Int @@ -220,3 +221,21 @@ model BillingPeriod { eliminatedAsOutlier Boolean wholeHomeHeatLossRate Float } + +model SummaryOutput { + // TODO: implement one to one for Case and Summary. + // Below is giving an error + id String @id @default(cuid()) + case Case @relation(fields: [caseId], references: [id], onDelete: Cascade, onUpdate: Cascade) + caseId String @unique + estimatedBalancePoint Float + otherFuelUsage Float + averageIndoorTemperature Float + differenceBetweenTiAndTbp Float + designTemperature Float + wholeHomeHeatLossRate Float + standardDeviationOfHeatLossRate Float + averageHeatLoad Float + maximumHeatLoad Float +} + From 9fe9cfa447b2529ccdf0ec300e190021e149b1c9 Mon Sep 17 00:00:00 2001 From: Ethan Strominger Date: Thu, 26 Sep 2024 12:11:42 -0400 Subject: [PATCH 06/26] Implement user-case many to many and change id to int Co-authored-by: AdamFinkle --- heat-stack/Dockerfile | 98 +++++++ heat-stack/Dockerfile.dockerignore | 9 + heat-stack/package-lock.json | 144 ++++++++++ heat-stack/package.json | 1 + heat-stack/prisma/ERD.md | 237 +++++++++++++++++ .../migration.sql | 248 ++++++++++++++++++ .../prisma/migrations/migration_lock.toml | 3 + heat-stack/prisma/schema.prisma | 60 +++-- 8 files changed, 772 insertions(+), 28 deletions(-) create mode 100644 heat-stack/Dockerfile create mode 100644 heat-stack/Dockerfile.dockerignore create mode 100644 heat-stack/prisma/ERD.md create mode 100644 heat-stack/prisma/migrations/20240926155816_added_case_user_association_table/migration.sql create mode 100644 heat-stack/prisma/migrations/migration_lock.toml diff --git a/heat-stack/Dockerfile b/heat-stack/Dockerfile new file mode 100644 index 00000000..3cd618a6 --- /dev/null +++ b/heat-stack/Dockerfile @@ -0,0 +1,98 @@ +# This file is moved to the root directory before building the image + +# base node image +FROM node:20-bookworm-slim as base + +# set for base and all layer that inherit from it +ENV NODE_ENV production + +# Install openssl for Prisma +RUN apt-get update && apt-get install -y fuse3 openssl sqlite3 ca-certificates + +# Install all node_modules, including dev dependencies +FROM base as deps + +WORKDIR /myapp + +ADD package.json package-lock.json .npmrc ./ +RUN npm install --include=dev + +# Setup production node_modules +FROM base as production-deps + +WORKDIR /myapp + +COPY --from=deps /myapp/node_modules /myapp/node_modules +ADD package.json package-lock.json .npmrc ./ +RUN npm prune --omit=dev + +# Build the app +FROM base as build + +ARG COMMIT_SHA +ENV COMMIT_SHA=$COMMIT_SHA + +# Use the following environment variables to configure Sentry +# ENV SENTRY_ORG= +# ENV SENTRY_PROJECT= + + +WORKDIR /myapp + +COPY --from=deps /myapp/node_modules /myapp/node_modules + +ADD prisma . +RUN npx prisma generate + +ADD . . + +# Mount the secret and set it as an environment variable and run the build +RUN --mount=type=secret,id=SENTRY_AUTH_TOKEN \ + export SENTRY_AUTH_TOKEN=$(cat /run/secrets/SENTRY_AUTH_TOKEN) && \ + npm run build + +# Finally, build the production image with minimal footprint +FROM base + +ENV FLY="true" +ENV LITEFS_DIR="/litefs/data" +ENV DATABASE_FILENAME="sqlite.db" +ENV DATABASE_PATH="$LITEFS_DIR/$DATABASE_FILENAME" +ENV DATABASE_URL="file:$DATABASE_PATH" +ENV CACHE_DATABASE_FILENAME="cache.db" +ENV CACHE_DATABASE_PATH="$LITEFS_DIR/$CACHE_DATABASE_FILENAME" +ENV INTERNAL_PORT="8080" +ENV PORT="8081" +ENV NODE_ENV="production" +# For WAL support: https://github.com/prisma/prisma-engines/issues/4675#issuecomment-1914383246 +ENV PRISMA_SCHEMA_DISABLE_ADVISORY_LOCK = "1" + +# add shortcut for connecting to database CLI +RUN echo "#!/bin/sh\nset -x\nsqlite3 \$DATABASE_URL" > /usr/local/bin/database-cli && chmod +x /usr/local/bin/database-cli + +WORKDIR /myapp + +# Generate random value and save it to .env file which will be loaded by dotenv +RUN INTERNAL_COMMAND_TOKEN=$(openssl rand -hex 32) && \ + echo "INTERNAL_COMMAND_TOKEN=$INTERNAL_COMMAND_TOKEN" > .env + +COPY --from=production-deps /myapp/node_modules /myapp/node_modules +COPY --from=build /myapp/node_modules/.prisma /myapp/node_modules/.prisma + +COPY --from=build /myapp/server-build /myapp/server-build +COPY --from=build /myapp/build /myapp/build + +# HEAT Stack custom line for Pyodide +COPY --from=build /myapp/public /myapp/public +COPY --from=build /myapp/package.json /myapp/package.json +COPY --from=build /myapp/prisma /myapp/prisma +COPY --from=build /myapp/app/components/ui/icons /myapp/app/components/ui/icons + +# prepare for litefs +COPY --from=flyio/litefs:0.5.11 /usr/local/bin/litefs /usr/local/bin/litefs +ADD other/litefs.yml /etc/litefs.yml +RUN mkdir -p /data ${LITEFS_DIR} + +ADD . . + +CMD ["litefs", "mount"] diff --git a/heat-stack/Dockerfile.dockerignore b/heat-stack/Dockerfile.dockerignore new file mode 100644 index 00000000..6e187657 --- /dev/null +++ b/heat-stack/Dockerfile.dockerignore @@ -0,0 +1,9 @@ +# This file is moved to the root directory before building the image + +/node_modules +*.log +.DS_Store +.env +/.cache +/public/build +/build diff --git a/heat-stack/package-lock.json b/heat-stack/package-lock.json index 6cf192c9..01783033 100644 --- a/heat-stack/package-lock.json +++ b/heat-stack/package-lock.json @@ -117,6 +117,7 @@ "prettier-plugin-tailwindcss": "^0.6.5", "prisma": "^5.19.1", "remix-flat-routes": "^0.6.5", + "ts-node": "^10.9.2", "tsx": "^4.16.2", "typescript": "^5.5.3", "vite": "^5.3.4", @@ -874,6 +875,28 @@ "zod": "^3.21.0" } }, + "node_modules/@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@cspotcode/source-map-support/node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, "node_modules/@emotion/hash": { "version": "0.9.1", "resolved": "https://registry.npmjs.org/@emotion/hash/-/hash-0.9.1.tgz", @@ -6334,6 +6357,30 @@ "dev": true, "license": "MIT" }, + "node_modules/@tsconfig/node10": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz", + "integrity": "sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==", + "dev": true + }, + "node_modules/@tsconfig/node12": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", + "dev": true + }, + "node_modules/@tsconfig/node14": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", + "dev": true + }, + "node_modules/@tsconfig/node16": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", + "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", + "dev": true + }, "node_modules/@types/acorn": { "version": "4.0.6", "resolved": "https://registry.npmjs.org/@types/acorn/-/acorn-4.0.6.tgz", @@ -8113,6 +8160,18 @@ "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } }, + "node_modules/acorn-walk": { + "version": "8.3.4", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.4.tgz", + "integrity": "sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g==", + "dev": true, + "dependencies": { + "acorn": "^8.11.0" + }, + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/address": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/address/-/address-2.0.3.tgz", @@ -9500,6 +9559,12 @@ } } }, + "node_modules/create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "dev": true + }, "node_modules/cross-env": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", @@ -14049,6 +14114,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "dev": true + }, "node_modules/markdown-extensions": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/markdown-extensions/-/markdown-extensions-1.1.1.tgz", @@ -20105,6 +20176,64 @@ "integrity": "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==", "license": "Apache-2.0" }, + "node_modules/ts-node": { + "version": "10.9.2", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", + "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", + "dev": true, + "dependencies": { + "@cspotcode/source-map-support": "^0.8.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.1", + "yn": "3.1.1" + }, + "bin": { + "ts-node": "dist/bin.js", + "ts-node-cwd": "dist/bin-cwd.js", + "ts-node-esm": "dist/bin-esm.js", + "ts-node-script": "dist/bin-script.js", + "ts-node-transpile-only": "dist/bin-transpile.js", + "ts-script": "dist/bin-script-deprecated.js" + }, + "peerDependencies": { + "@swc/core": ">=1.2.50", + "@swc/wasm": ">=1.2.50", + "@types/node": "*", + "typescript": ">=2.7" + }, + "peerDependenciesMeta": { + "@swc/core": { + "optional": true + }, + "@swc/wasm": { + "optional": true + } + } + }, + "node_modules/ts-node/node_modules/arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "dev": true + }, + "node_modules/ts-node/node_modules/diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true, + "engines": { + "node": ">=0.3.1" + } + }, "node_modules/tsconfig-paths": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-4.2.0.tgz", @@ -21273,6 +21402,12 @@ "node": ">=6" } }, + "node_modules/v8-compile-cache-lib": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", + "dev": true + }, "node_modules/validate-npm-package-license": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", @@ -22591,6 +22726,15 @@ "node": ">=8" } }, + "node_modules/yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", diff --git a/heat-stack/package.json b/heat-stack/package.json index 1e742388..81a2352a 100644 --- a/heat-stack/package.json +++ b/heat-stack/package.json @@ -155,6 +155,7 @@ "prettier-plugin-tailwindcss": "^0.6.5", "prisma": "^5.19.1", "remix-flat-routes": "^0.6.5", + "ts-node": "^10.9.2", "tsx": "^4.16.2", "typescript": "^5.5.3", "vite": "^5.3.4", diff --git a/heat-stack/prisma/ERD.md b/heat-stack/prisma/ERD.md new file mode 100644 index 00000000..4d226080 --- /dev/null +++ b/heat-stack/prisma/ERD.md @@ -0,0 +1,237 @@ +# Home Energy Analysis Tool +> Generated by [`prisma-markdown`](https://github.com/samchon/prisma-markdown) + +- [default](#default) + +## default +```mermaid +erDiagram +"User" { + String id PK + String email UK + String username UK + String name "nullable" + DateTime createdAt + DateTime updatedAt +} +"Note" { + String id PK + String title + String content + DateTime createdAt + DateTime updatedAt + String ownerId FK +} +"NoteImage" { + String id PK + String altText "nullable" + String contentType + Bytes blob + DateTime createdAt + DateTime updatedAt + String noteId FK +} +"UserImage" { + String id PK + String altText "nullable" + String contentType + Bytes blob + DateTime createdAt + DateTime updatedAt + String userId FK +} +"Password" { + String hash + String userId FK +} +"Session" { + String id PK + DateTime expirationDate + DateTime createdAt + DateTime updatedAt + String userId FK +} +"Permission" { + String id PK + String action + String entity + String access + String description + DateTime createdAt + DateTime updatedAt +} +"Role" { + String id PK + String name UK + String description + DateTime createdAt + DateTime updatedAt +} +"Verification" { + String id PK + DateTime createdAt + String type + String target + String secret + String algorithm + Int digits + Int period + String charSet + DateTime expiresAt "nullable" +} +"Connection" { + String id PK + String providerName + String providerId + DateTime createdAt + DateTime updatedAt + String userId FK +} +"OilPropaneBillingRecordInput" { + String id PK + DateTime period_end_date + Float gallons + String inclusion_override +} +"_RoleToUser" { + String A FK + String B FK +} +"_PermissionToRole" { + String A FK + String B FK +} +"Note" }o--|| "User" : owner +"NoteImage" }o--|| "Note" : note +"UserImage" |o--|| "User" : user +"Password" |o--|| "User" : user +"Session" }o--|| "User" : user +"Connection" }o--|| "User" : user +"_RoleToUser" }o--|| "Role" : Role +"_RoleToUser" }o--|| "User" : User +"_PermissionToRole" }o--|| "Permission" : Permission +"_PermissionToRole" }o--|| "Role" : Role +``` + +### `User` + +**Properties** + - `id`: + - `email`: + - `username`: + - `name`: + - `createdAt`: + - `updatedAt`: + +### `Note` + +**Properties** + - `id`: + - `title`: + - `content`: + - `createdAt`: + - `updatedAt`: + - `ownerId`: + +### `NoteImage` + +**Properties** + - `id`: + - `altText`: + - `contentType`: + - `blob`: + - `createdAt`: + - `updatedAt`: + - `noteId`: + +### `UserImage` + +**Properties** + - `id`: + - `altText`: + - `contentType`: + - `blob`: + - `createdAt`: + - `updatedAt`: + - `userId`: + +### `Password` + +**Properties** + - `hash`: + - `userId`: + +### `Session` + +**Properties** + - `id`: + - `expirationDate`: + - `createdAt`: + - `updatedAt`: + - `userId`: + +### `Permission` + +**Properties** + - `id`: + - `action`: + - `entity`: + - `access`: + - `description`: + - `createdAt`: + - `updatedAt`: + +### `Role` + +**Properties** + - `id`: + - `name`: + - `description`: + - `createdAt`: + - `updatedAt`: + +### `Verification` + +**Properties** + - `id`: + - `createdAt`: + - `type`: The type of verification, e.g. "email" or "phone" + - `target`: The thing we're trying to verify, e.g. a user's email or phone number + - `secret`: The secret key used to generate the otp + - `algorithm`: The algorithm used to generate the otp + - `digits`: The number of digits in the otp + - `period`: The number of seconds the otp is valid for + - `charSet`: The valid characters for the otp + - `expiresAt`: When it's safe to delete this verification + +### `Connection` + +**Properties** + - `id`: + - `providerName`: + - `providerId`: + - `createdAt`: + - `updatedAt`: + - `userId`: + +### `OilPropaneBillingRecordInput` + +**Properties** + - `id`: + - `period_end_date`: + - `gallons`: + - `inclusion_override`: + +### `_RoleToUser` +Pair relationship table between [Role](#Role) and [User](#User) + +**Properties** + - `A`: + - `B`: + +### `_PermissionToRole` +Pair relationship table between [Permission](#Permission) and [Role](#Role) + +**Properties** + - `A`: + - `B`: \ No newline at end of file diff --git a/heat-stack/prisma/migrations/20240926155816_added_case_user_association_table/migration.sql b/heat-stack/prisma/migrations/20240926155816_added_case_user_association_table/migration.sql new file mode 100644 index 00000000..76bca36b --- /dev/null +++ b/heat-stack/prisma/migrations/20240926155816_added_case_user_association_table/migration.sql @@ -0,0 +1,248 @@ +-- CreateTable +CREATE TABLE "User" ( + "id" TEXT NOT NULL PRIMARY KEY, + "email" TEXT NOT NULL, + "username" TEXT NOT NULL, + "name" TEXT, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL +); + +-- CreateTable +CREATE TABLE "Note" ( + "id" TEXT NOT NULL PRIMARY KEY, + "title" TEXT NOT NULL, + "content" TEXT NOT NULL, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL, + "ownerId" TEXT NOT NULL, + CONSTRAINT "Note_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); + +-- CreateTable +CREATE TABLE "NoteImage" ( + "id" TEXT NOT NULL PRIMARY KEY, + "altText" TEXT, + "contentType" TEXT NOT NULL, + "blob" BLOB NOT NULL, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL, + "noteId" TEXT NOT NULL, + CONSTRAINT "NoteImage_noteId_fkey" FOREIGN KEY ("noteId") REFERENCES "Note" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); + +-- CreateTable +CREATE TABLE "UserImage" ( + "id" TEXT NOT NULL PRIMARY KEY, + "altText" TEXT, + "contentType" TEXT NOT NULL, + "blob" BLOB NOT NULL, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL, + "userId" TEXT NOT NULL, + CONSTRAINT "UserImage_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); + +-- CreateTable +CREATE TABLE "Password" ( + "hash" TEXT NOT NULL, + "userId" TEXT NOT NULL, + CONSTRAINT "Password_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); + +-- CreateTable +CREATE TABLE "Session" ( + "id" TEXT NOT NULL PRIMARY KEY, + "expirationDate" DATETIME NOT NULL, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL, + "userId" TEXT NOT NULL, + CONSTRAINT "Session_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); + +-- CreateTable +CREATE TABLE "Permission" ( + "id" TEXT NOT NULL PRIMARY KEY, + "action" TEXT NOT NULL, + "entity" TEXT NOT NULL, + "access" TEXT NOT NULL, + "description" TEXT NOT NULL DEFAULT '', + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL +); + +-- CreateTable +CREATE TABLE "Role" ( + "id" TEXT NOT NULL PRIMARY KEY, + "name" TEXT NOT NULL, + "description" TEXT NOT NULL DEFAULT '', + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL +); + +-- CreateTable +CREATE TABLE "Verification" ( + "id" TEXT NOT NULL PRIMARY KEY, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "type" TEXT NOT NULL, + "target" TEXT NOT NULL, + "secret" TEXT NOT NULL, + "algorithm" TEXT NOT NULL, + "digits" INTEGER NOT NULL, + "period" INTEGER NOT NULL, + "charSet" TEXT NOT NULL, + "expiresAt" DATETIME +); + +-- CreateTable +CREATE TABLE "Connection" ( + "id" TEXT NOT NULL PRIMARY KEY, + "providerName" TEXT NOT NULL, + "providerId" TEXT NOT NULL, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL, + "userId" TEXT NOT NULL, + CONSTRAINT "Connection_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); + +-- CreateTable +CREATE TABLE "Home" ( + "id" TEXT NOT NULL PRIMARY KEY, + "name" TEXT NOT NULL, + "address" TEXT NOT NULL, + "livingArea" REAL NOT NULL +); + +-- CreateTable +CREATE TABLE "Case" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "homeId" TEXT NOT NULL, + "summaryOutputId" TEXT NOT NULL, + "fuelType" TEXT NOT NULL, + "designTemperatureOverride" BOOLEAN NOT NULL, + "heatingSystemEfficiency" INTEGER NOT NULL, + "thermostatSetPoint" INTEGER NOT NULL, + "setbackTemperature" INTEGER NOT NULL, + "setbackHoursPerDay" INTEGER NOT NULL, + "numberOfOccupants" INTEGER NOT NULL, + "estimatedWaterHeatingEfficiency" INTEGER NOT NULL, + "standByLosses" INTEGER NOT NULL, + CONSTRAINT "Case_homeId_fkey" FOREIGN KEY ("homeId") REFERENCES "Home" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); + +-- CreateTable +CREATE TABLE "File" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "caseId" INTEGER NOT NULL, + "filePath" TEXT NOT NULL, + "description" TEXT NOT NULL, + CONSTRAINT "File_caseId_fkey" FOREIGN KEY ("caseId") REFERENCES "Case" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); + +-- CreateTable +CREATE TABLE "BillingPeriod" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "caseId" INTEGER NOT NULL, + "periodStartDate" DATETIME NOT NULL, + "periodEndDate" DATETIME NOT NULL, + "usage" REAL NOT NULL, + "analysisTypeOverride" BOOLEAN NOT NULL, + "inclusionOverride" BOOLEAN NOT NULL, + "originalAnalysisType" INTEGER NOT NULL, + "analysisType" INTEGER NOT NULL, + "defaultInclusionByCalculation" BOOLEAN NOT NULL, + "eliminatedAsOutlier" BOOLEAN NOT NULL, + "wholeHomeHeatLossRate" REAL NOT NULL, + CONSTRAINT "BillingPeriod_caseId_fkey" FOREIGN KEY ("caseId") REFERENCES "Case" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); + +-- CreateTable +CREATE TABLE "SummaryOutput" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "caseId" INTEGER NOT NULL, + "estimatedBalancePoint" REAL NOT NULL, + "otherFuelUsage" REAL NOT NULL, + "averageIndoorTemperature" REAL NOT NULL, + "differenceBetweenTiAndTbp" REAL NOT NULL, + "designTemperature" REAL NOT NULL, + "wholeHomeHeatLossRate" REAL NOT NULL, + "standardDeviationOfHeatLossRate" REAL NOT NULL, + "averageHeatLoad" REAL NOT NULL, + "maximumHeatLoad" REAL NOT NULL, + CONSTRAINT "SummaryOutput_caseId_fkey" FOREIGN KEY ("caseId") REFERENCES "Case" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); + +-- CreateTable +CREATE TABLE "CaseUser" ( + "caseId" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "userId" TEXT NOT NULL, + CONSTRAINT "CaseUser_caseId_fkey" FOREIGN KEY ("caseId") REFERENCES "Case" ("id") ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT "CaseUser_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); + +-- CreateTable +CREATE TABLE "_PermissionToRole" ( + "A" TEXT NOT NULL, + "B" TEXT NOT NULL, + CONSTRAINT "_PermissionToRole_A_fkey" FOREIGN KEY ("A") REFERENCES "Permission" ("id") ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT "_PermissionToRole_B_fkey" FOREIGN KEY ("B") REFERENCES "Role" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); + +-- CreateTable +CREATE TABLE "_RoleToUser" ( + "A" TEXT NOT NULL, + "B" TEXT NOT NULL, + CONSTRAINT "_RoleToUser_A_fkey" FOREIGN KEY ("A") REFERENCES "Role" ("id") ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT "_RoleToUser_B_fkey" FOREIGN KEY ("B") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); + +-- CreateIndex +CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); + +-- CreateIndex +CREATE UNIQUE INDEX "User_username_key" ON "User"("username"); + +-- CreateIndex +CREATE INDEX "Note_ownerId_idx" ON "Note"("ownerId"); + +-- CreateIndex +CREATE INDEX "Note_ownerId_updatedAt_idx" ON "Note"("ownerId", "updatedAt"); + +-- CreateIndex +CREATE INDEX "NoteImage_noteId_idx" ON "NoteImage"("noteId"); + +-- CreateIndex +CREATE UNIQUE INDEX "UserImage_userId_key" ON "UserImage"("userId"); + +-- CreateIndex +CREATE UNIQUE INDEX "Password_userId_key" ON "Password"("userId"); + +-- CreateIndex +CREATE INDEX "Session_userId_idx" ON "Session"("userId"); + +-- CreateIndex +CREATE UNIQUE INDEX "Permission_action_entity_access_key" ON "Permission"("action", "entity", "access"); + +-- CreateIndex +CREATE UNIQUE INDEX "Role_name_key" ON "Role"("name"); + +-- CreateIndex +CREATE UNIQUE INDEX "Verification_target_type_key" ON "Verification"("target", "type"); + +-- CreateIndex +CREATE UNIQUE INDEX "Connection_providerName_providerId_key" ON "Connection"("providerName", "providerId"); + +-- CreateIndex +CREATE UNIQUE INDEX "Case_summaryOutputId_key" ON "Case"("summaryOutputId"); + +-- CreateIndex +CREATE UNIQUE INDEX "_PermissionToRole_AB_unique" ON "_PermissionToRole"("A", "B"); + +-- CreateIndex +CREATE INDEX "_PermissionToRole_B_index" ON "_PermissionToRole"("B"); + +-- CreateIndex +CREATE UNIQUE INDEX "_RoleToUser_AB_unique" ON "_RoleToUser"("A", "B"); + +-- CreateIndex +CREATE INDEX "_RoleToUser_B_index" ON "_RoleToUser"("B"); diff --git a/heat-stack/prisma/migrations/migration_lock.toml b/heat-stack/prisma/migrations/migration_lock.toml new file mode 100644 index 00000000..e5e5c470 --- /dev/null +++ b/heat-stack/prisma/migrations/migration_lock.toml @@ -0,0 +1,3 @@ +# Please do not edit this file manually +# It should be added in your version-control system (i.e. Git) +provider = "sqlite" \ No newline at end of file diff --git a/heat-stack/prisma/schema.prisma b/heat-stack/prisma/schema.prisma index b4f2a8e3..cfff9b0b 100644 --- a/heat-stack/prisma/schema.prisma +++ b/heat-stack/prisma/schema.prisma @@ -11,9 +11,11 @@ datasource db { } model User { - id String @id @default(cuid()) - email String @unique - username String @unique + id String @id @default(cuid()) + caseUser CaseUser[] + + email String @unique + username String @unique name String? createdAt DateTime @default(now()) @@ -174,12 +176,12 @@ model Home { address String livingArea Float Case Case[] - File File[] } model Case { - id String @id @default(cuid()) + id Int @id @default(autoincrement()) home Home @relation(fields: [homeId], references: [id], onDelete: Cascade, onUpdate: Cascade) + caseUser CaseUser[] summaryOutput SummaryOutput[] // There can be only one summaryOutput, but attempting anything else yielded an error. homeId String summaryOutputId String @unique @@ -197,45 +199,47 @@ model Case { } model File { - id String @id @default(cuid()) - home Home @relation(fields: [homeId], references: [id], onDelete: Cascade, onUpdate: Cascade) + id Int @id @default(autoincrement()) case Case @relation(fields: [caseId], references: [id], onDelete: Cascade, onUpdate: Cascade) - homeId String - caseId String + caseId Int filePath String description String } model BillingPeriod { - id String @id @default(cuid()) + id Int @id @default(autoincrement()) case Case @relation(fields: [caseId], references: [id], onDelete: Cascade, onUpdate: Cascade) - caseId String + caseId Int periodStartDate DateTime periodEndDate DateTime usage Float analysisTypeOverride Boolean inclusionOverride Boolean originalAnalysisType Int - analysisType Int + analysisType Int defaultInclusionByCalculation Boolean eliminatedAsOutlier Boolean wholeHomeHeatLossRate Float } model SummaryOutput { - // TODO: implement one to one for Case and Summary. - // Below is giving an error - id String @id @default(cuid()) - case Case @relation(fields: [caseId], references: [id], onDelete: Cascade, onUpdate: Cascade) - caseId String @unique - estimatedBalancePoint Float - otherFuelUsage Float - averageIndoorTemperature Float - differenceBetweenTiAndTbp Float - designTemperature Float - wholeHomeHeatLossRate Float - standardDeviationOfHeatLossRate Float - averageHeatLoad Float - maximumHeatLoad Float -} - + id Int @id @default(autoincrement()) + case Case @relation(fields: [caseId], references: [id], onDelete: Cascade, onUpdate: Cascade) + caseId Int + estimatedBalancePoint Float + otherFuelUsage Float + averageIndoorTemperature Float + differenceBetweenTiAndTbp Float + designTemperature Float + wholeHomeHeatLossRate Float + standardDeviationOfHeatLossRate Float + averageHeatLoad Float + maximumHeatLoad Float +} + +model CaseUser { + case Case @relation(fields: [caseId], references: [id], onDelete: Cascade, onUpdate: Cascade) + user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: Cascade) + caseId Int @id @default(autoincrement()) + userId String +} \ No newline at end of file From 4825e0241415cd1ca237e8b6b909c7e119e73bee Mon Sep 17 00:00:00 2001 From: Ethan Strominger Date: Mon, 30 Sep 2024 13:39:01 -0400 Subject: [PATCH 07/26] Added contacts. --- .../migration.sql | 35 +++++++++++++++++++ heat-stack/prisma/schema.prisma | 18 ++++++---- 2 files changed, 47 insertions(+), 6 deletions(-) create mode 100644 heat-stack/prisma/migrations/20240930173652_added_contacts_and_made_summary_output_case_id_unique/migration.sql diff --git a/heat-stack/prisma/migrations/20240930173652_added_contacts_and_made_summary_output_case_id_unique/migration.sql b/heat-stack/prisma/migrations/20240930173652_added_contacts_and_made_summary_output_case_id_unique/migration.sql new file mode 100644 index 00000000..d92e6000 --- /dev/null +++ b/heat-stack/prisma/migrations/20240930173652_added_contacts_and_made_summary_output_case_id_unique/migration.sql @@ -0,0 +1,35 @@ +/* + Warnings: + + - A unique constraint covering the columns `[caseId]` on the table `SummaryOutput` will be added. If there are existing duplicate values, this will fail. + - Added the required column `contact_1_email_address` to the `Home` table without a default value. This is not possible if the table is not empty. + - Added the required column `contact_1_name` to the `Home` table without a default value. This is not possible if the table is not empty. + - Added the required column `contact_1_phone` to the `Home` table without a default value. This is not possible if the table is not empty. + - Added the required column `contact_2_email_address` to the `Home` table without a default value. This is not possible if the table is not empty. + - Added the required column `contact_2_name` to the `Home` table without a default value. This is not possible if the table is not empty. + - Added the required column `contact_2_phone` to the `Home` table without a default value. This is not possible if the table is not empty. + +*/ +-- RedefineTables +PRAGMA defer_foreign_keys=ON; +PRAGMA foreign_keys=OFF; +CREATE TABLE "new_Home" ( + "id" TEXT NOT NULL PRIMARY KEY, + "name" TEXT NOT NULL, + "contact_1_name" TEXT NOT NULL, + "contact_1_email_address" TEXT NOT NULL, + "contact_1_phone" TEXT NOT NULL, + "contact_2_name" TEXT NOT NULL, + "contact_2_email_address" TEXT NOT NULL, + "contact_2_phone" TEXT NOT NULL, + "address" TEXT NOT NULL, + "livingArea" REAL NOT NULL +); +INSERT INTO "new_Home" ("address", "id", "livingArea", "name") SELECT "address", "id", "livingArea", "name" FROM "Home"; +DROP TABLE "Home"; +ALTER TABLE "new_Home" RENAME TO "Home"; +PRAGMA foreign_keys=ON; +PRAGMA defer_foreign_keys=OFF; + +-- CreateIndex +CREATE UNIQUE INDEX "SummaryOutput_caseId_key" ON "SummaryOutput"("caseId"); diff --git a/heat-stack/prisma/schema.prisma b/heat-stack/prisma/schema.prisma index cfff9b0b..7b235fd7 100644 --- a/heat-stack/prisma/schema.prisma +++ b/heat-stack/prisma/schema.prisma @@ -171,11 +171,17 @@ model Connection { } model Home { - id String @id @default(cuid()) - name String - address String - livingArea Float - Case Case[] + id String @id @default(cuid()) + name String + contact_1_name String + contact_1_email_address String + contact_1_phone String + contact_2_name String + contact_2_email_address String + contact_2_phone String + address String + livingArea Float + Case Case[] } model Case { @@ -225,7 +231,7 @@ model BillingPeriod { model SummaryOutput { id Int @id @default(autoincrement()) case Case @relation(fields: [caseId], references: [id], onDelete: Cascade, onUpdate: Cascade) - caseId Int + caseId Int @unique estimatedBalancePoint Float otherFuelUsage Float averageIndoorTemperature Float From d081bc9fef96c0a9080a69f64d045e1f80fabdec Mon Sep 17 00:00:00 2001 From: Ethan Strominger Date: Mon, 30 Sep 2024 13:43:08 -0400 Subject: [PATCH 08/26] Required caseId and userId combination to be unique. --- .../migration.sql | 8 ++++++++ heat-stack/prisma/schema.prisma | 1 + 2 files changed, 9 insertions(+) create mode 100644 heat-stack/prisma/migrations/20240930174229_required_case_user_case_id_user_id_combination_to_be_unique/migration.sql diff --git a/heat-stack/prisma/migrations/20240930174229_required_case_user_case_id_user_id_combination_to_be_unique/migration.sql b/heat-stack/prisma/migrations/20240930174229_required_case_user_case_id_user_id_combination_to_be_unique/migration.sql new file mode 100644 index 00000000..3fc1b083 --- /dev/null +++ b/heat-stack/prisma/migrations/20240930174229_required_case_user_case_id_user_id_combination_to_be_unique/migration.sql @@ -0,0 +1,8 @@ +/* + Warnings: + + - A unique constraint covering the columns `[caseId,userId]` on the table `CaseUser` will be added. If there are existing duplicate values, this will fail. + +*/ +-- CreateIndex +CREATE UNIQUE INDEX "CaseUser_caseId_userId_key" ON "CaseUser"("caseId", "userId"); diff --git a/heat-stack/prisma/schema.prisma b/heat-stack/prisma/schema.prisma index 7b235fd7..7f318eb6 100644 --- a/heat-stack/prisma/schema.prisma +++ b/heat-stack/prisma/schema.prisma @@ -248,4 +248,5 @@ model CaseUser { user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: Cascade) caseId Int @id @default(autoincrement()) userId String + @@unique([caseId, userId]) } \ No newline at end of file From cd8e7980dd79d102f37dca2e1926caef58df0f8e Mon Sep 17 00:00:00 2001 From: Ethan Strominger Date: Fri, 4 Oct 2024 12:39:23 -0400 Subject: [PATCH 09/26] Reimplement schema.prisma based on ERD Co-authored-by: AdamFinkle --- .../migration.sql | 167 ++++++++++++++++++ heat-stack/prisma/schema.prisma | 134 ++++++++------ 2 files changed, 247 insertions(+), 54 deletions(-) create mode 100644 heat-stack/prisma/migrations/20241004163840_changed_models_to_reflect_erd/migration.sql diff --git a/heat-stack/prisma/migrations/20241004163840_changed_models_to_reflect_erd/migration.sql b/heat-stack/prisma/migrations/20241004163840_changed_models_to_reflect_erd/migration.sql new file mode 100644 index 00000000..a28b9c50 --- /dev/null +++ b/heat-stack/prisma/migrations/20241004163840_changed_models_to_reflect_erd/migration.sql @@ -0,0 +1,167 @@ +/* + Warnings: + + - You are about to drop the `BillingPeriod` table. If the table is not empty, all the data it contains will be lost. + - You are about to drop the `File` table. If the table is not empty, all the data it contains will be lost. + - You are about to drop the `Home` table. If the table is not empty, all the data it contains will be lost. + - You are about to drop the `SummaryOutput` table. If the table is not empty, all the data it contains will be lost. + - You are about to drop the column `designTemperatureOverride` on the `Case` table. All the data in the column will be lost. + - You are about to drop the column `estimatedWaterHeatingEfficiency` on the `Case` table. All the data in the column will be lost. + - You are about to drop the column `fuelType` on the `Case` table. All the data in the column will be lost. + - You are about to drop the column `heatingSystemEfficiency` on the `Case` table. All the data in the column will be lost. + - You are about to drop the column `homeId` on the `Case` table. All the data in the column will be lost. + - You are about to drop the column `numberOfOccupants` on the `Case` table. All the data in the column will be lost. + - You are about to drop the column `setbackHoursPerDay` on the `Case` table. All the data in the column will be lost. + - You are about to drop the column `setbackTemperature` on the `Case` table. All the data in the column will be lost. + - You are about to drop the column `standByLosses` on the `Case` table. All the data in the column will be lost. + - You are about to drop the column `summaryOutputId` on the `Case` table. All the data in the column will be lost. + - You are about to drop the column `thermostatSetPoint` on the `Case` table. All the data in the column will be lost. + - The primary key for the `CaseUser` table will be changed. If it partially fails, the table could be left without primary key constraint. + - You are about to drop the column `caseId` on the `CaseUser` table. All the data in the column will be lost. + - Added the required column `homeOwnerId` to the `Case` table without a default value. This is not possible if the table is not empty. + - Added the required column `locationId` to the `Case` table without a default value. This is not possible if the table is not empty. + - Added the required column `analysisInputId` to the `CaseUser` table without a default value. This is not possible if the table is not empty. + +*/ +-- DropIndex +DROP INDEX "SummaryOutput_caseId_key"; + +-- DropTable +PRAGMA foreign_keys=off; +DROP TABLE "BillingPeriod"; +PRAGMA foreign_keys=on; + +-- DropTable +PRAGMA foreign_keys=off; +DROP TABLE "File"; +PRAGMA foreign_keys=on; + +-- DropTable +PRAGMA foreign_keys=off; +DROP TABLE "Home"; +PRAGMA foreign_keys=on; + +-- DropTable +PRAGMA foreign_keys=off; +DROP TABLE "SummaryOutput"; +PRAGMA foreign_keys=on; + +-- CreateTable +CREATE TABLE "AnalysisInput" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "caseId" INTEGER NOT NULL, + "locationId" INTEGER NOT NULL, + "summaryOutputId" TEXT NOT NULL, + "fuelType" TEXT NOT NULL, + "designTemperatureOverride" BOOLEAN NOT NULL, + "heatingSystemEfficiency" INTEGER NOT NULL, + "thermostatSetPoint" INTEGER NOT NULL, + "setbackTemperature" INTEGER NOT NULL, + "setbackHoursPerDay" INTEGER NOT NULL, + "numberOfOccupants" INTEGER NOT NULL, + "estimatedWaterHeatingEfficiency" INTEGER NOT NULL, + "standByLosses" INTEGER NOT NULL, + "livingArea" REAL NOT NULL, + CONSTRAINT "AnalysisInput_locationId_fkey" FOREIGN KEY ("locationId") REFERENCES "Location" ("id") ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT "AnalysisInput_caseId_fkey" FOREIGN KEY ("caseId") REFERENCES "Case" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); + +-- CreateTable +CREATE TABLE "ProcessedEnergyBill" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "analysisInputId" INTEGER NOT NULL, + "periodStartDate" DATETIME NOT NULL, + "periodEndDate" DATETIME NOT NULL, + "usageTherms" REAL NOT NULL, + "wholeHomeHeatLossRate" REAL NOT NULL, + "analysisType" INTEGER NOT NULL, + "defaultInclusion" BOOLEAN NOT NULL, + "inclusionOverride" BOOLEAN NOT NULL, + CONSTRAINT "ProcessedEnergyBill_analysisInputId_fkey" FOREIGN KEY ("analysisInputId") REFERENCES "AnalysisInput" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); + +-- CreateTable +CREATE TABLE "AnalysisOutput" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "analysisInputId" INTEGER NOT NULL, + "estimatedBalancePoint" REAL NOT NULL, + "otherFuelUsage" REAL NOT NULL, + "averageIndoorTemperature" REAL NOT NULL, + "differenceBetweenTiAndTbp" REAL NOT NULL, + "designTemperature" REAL NOT NULL, + "wholeHomeHeatLossRate" REAL NOT NULL, + "standardDeviationOfHeatLossRate" REAL NOT NULL, + "averageHeatLoad" REAL NOT NULL, + "maximumHeatLoad" REAL NOT NULL, + CONSTRAINT "AnalysisOutput_analysisInputId_fkey" FOREIGN KEY ("analysisInputId") REFERENCES "AnalysisInput" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); + +-- CreateTable +CREATE TABLE "EnergyDataFile" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "provider" TEXT NOT NULL, + "fuelType" TEXT NOT NULL, + "precedingDeliveryDate" DATETIME NOT NULL, + "filePath" TEXT NOT NULL, + "description" TEXT NOT NULL +); + +-- CreateTable +CREATE TABLE "AnalysisInputEnergyDataFile" ( + "analysisInputId" INTEGER NOT NULL, + "energyDataFileId" INTEGER NOT NULL, + CONSTRAINT "AnalysisInputEnergyDataFile_analysisInputId_fkey" FOREIGN KEY ("analysisInputId") REFERENCES "AnalysisInput" ("id") ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT "AnalysisInputEnergyDataFile_energyDataFileId_fkey" FOREIGN KEY ("energyDataFileId") REFERENCES "EnergyDataFile" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); + +-- CreateTable +CREATE TABLE "HomeOwner" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "name" TEXT NOT NULL, + "contact_1_name" TEXT NOT NULL, + "contact_1_email_address" TEXT NOT NULL, + "contact_1_phone" TEXT NOT NULL, + "contact_2_name" TEXT NOT NULL, + "contact_2_email_address" TEXT NOT NULL, + "contact_2_phone" TEXT NOT NULL +); + +-- CreateTable +CREATE TABLE "Location" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "contact_2_email_address" TEXT NOT NULL, + "contact_2_phone" TEXT NOT NULL, + "address" TEXT NOT NULL +); + +-- RedefineTables +PRAGMA defer_foreign_keys=ON; +PRAGMA foreign_keys=OFF; +CREATE TABLE "new_Case" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "homeOwnerId" INTEGER NOT NULL, + "locationId" INTEGER NOT NULL, + CONSTRAINT "Case_homeOwnerId_fkey" FOREIGN KEY ("homeOwnerId") REFERENCES "HomeOwner" ("id") ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT "Case_locationId_fkey" FOREIGN KEY ("locationId") REFERENCES "Location" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); +INSERT INTO "new_Case" ("id") SELECT "id" FROM "Case"; +DROP TABLE "Case"; +ALTER TABLE "new_Case" RENAME TO "Case"; +CREATE TABLE "new_CaseUser" ( + "analysisInputId" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "userId" TEXT NOT NULL, + CONSTRAINT "CaseUser_analysisInputId_fkey" FOREIGN KEY ("analysisInputId") REFERENCES "AnalysisInput" ("id") ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT "CaseUser_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); +INSERT INTO "new_CaseUser" ("userId") SELECT "userId" FROM "CaseUser"; +DROP TABLE "CaseUser"; +ALTER TABLE "new_CaseUser" RENAME TO "CaseUser"; +CREATE UNIQUE INDEX "CaseUser_analysisInputId_userId_key" ON "CaseUser"("analysisInputId", "userId"); +PRAGMA foreign_keys=ON; +PRAGMA defer_foreign_keys=OFF; + +-- CreateIndex +CREATE UNIQUE INDEX "AnalysisInput_summaryOutputId_key" ON "AnalysisInput"("summaryOutputId"); + +-- CreateIndex +CREATE UNIQUE INDEX "AnalysisInputEnergyDataFile_analysisInputId_energyDataFileId_key" ON "AnalysisInputEnergyDataFile"("analysisInputId", "energyDataFileId"); diff --git a/heat-stack/prisma/schema.prisma b/heat-stack/prisma/schema.prisma index 7f318eb6..96fbe623 100644 --- a/heat-stack/prisma/schema.prisma +++ b/heat-stack/prisma/schema.prisma @@ -170,26 +170,16 @@ model Connection { @@unique([providerName, providerId]) } -model Home { - id String @id @default(cuid()) - name String - contact_1_name String - contact_1_email_address String - contact_1_phone String - contact_2_name String - contact_2_email_address String - contact_2_phone String - address String - livingArea Float - Case Case[] -} - -model Case { +// HEAT schema starts here +model AnalysisInput { id Int @id @default(autoincrement()) - home Home @relation(fields: [homeId], references: [id], onDelete: Cascade, onUpdate: Cascade) + location Location @relation(fields: [locationId], references: [id], onDelete: Cascade, onUpdate: Cascade) caseUser CaseUser[] - summaryOutput SummaryOutput[] // There can be only one summaryOutput, but attempting anything else yielded an error. - homeId String + analysisOutput AnalysisOutput[] + analysisInputEnergyDataFile AnalysisInputEnergyDataFile[] + case Case @relation(fields: [caseId], references: [id], onDelete: Cascade, onUpdate: Cascade) + caseId Int + locationId Int summaryOutputId String @unique fuelType String designTemperatureOverride Boolean @@ -200,38 +190,27 @@ model Case { numberOfOccupants Int estimatedWaterHeatingEfficiency Int standByLosses Int - File File[] - BillingPeriod BillingPeriod[] -} - -model File { - id Int @id @default(autoincrement()) - case Case @relation(fields: [caseId], references: [id], onDelete: Cascade, onUpdate: Cascade) - caseId Int - filePath String - description String -} - -model BillingPeriod { - id Int @id @default(autoincrement()) - case Case @relation(fields: [caseId], references: [id], onDelete: Cascade, onUpdate: Cascade) - caseId Int - periodStartDate DateTime - periodEndDate DateTime - usage Float - analysisTypeOverride Boolean - inclusionOverride Boolean - originalAnalysisType Int - analysisType Int - defaultInclusionByCalculation Boolean - eliminatedAsOutlier Boolean - wholeHomeHeatLossRate Float -} - -model SummaryOutput { + processedEnergyBill ProcessedEnergyBill[] + livingArea Float +} + +model ProcessedEnergyBill { + id Int @id @default(autoincrement()) + AnalysisInput AnalysisInput @relation(fields: [analysisInputId], references: [id], onDelete: Cascade, onUpdate: Cascade) + analysisInputId Int + periodStartDate DateTime + periodEndDate DateTime + usageTherms Float + wholeHomeHeatLossRate Float + analysisType Int + defaultInclusion Boolean + inclusionOverride Boolean +} + +model AnalysisOutput { id Int @id @default(autoincrement()) - case Case @relation(fields: [caseId], references: [id], onDelete: Cascade, onUpdate: Cascade) - caseId Int @unique + AnalysisInput AnalysisInput @relation(fields: [analysisInputId], references: [id], onDelete: Cascade, onUpdate: Cascade) + analysisInputId Int estimatedBalancePoint Float otherFuelUsage Float averageIndoorTemperature Float @@ -243,10 +222,57 @@ model SummaryOutput { maximumHeatLoad Float } +model EnergyDataFile { + id Int @id @default(autoincrement()) + provider String + fuelType String + precedingDeliveryDate DateTime + filePath String + description String + AnalysisInputEnergyDataFile AnalysisInputEnergyDataFile[] +} + +model AnalysisInputEnergyDataFile { + analysisInput AnalysisInput @relation(fields: [analysisInputId], references: [id], onDelete: Cascade, onUpdate: Cascade) + analysisInputId Int + EnergyDataFile EnergyDataFile @relation(fields: [energyDataFileId], references: [id], onDelete: Cascade, onUpdate: Cascade) + energyDataFileId Int + @@unique([analysisInputId, energyDataFileId]) +} + +model Case { + id Int @id @default(autoincrement()) + homeOwner HomeOwner @relation(fields: [homeOwnerId], references: [id], onDelete: Cascade, onUpdate: Cascade) + homeOwnerId Int + location Location @relation(fields: [locationId], references: [id], onDelete: Cascade, onUpdate: Cascade) + locationId Int + analysisInput AnalysisInput[] +} + +model HomeOwner { + id Int @id @default(autoincrement()) + case Case[] + name String + contact_1_name String + contact_1_email_address String + contact_1_phone String + contact_2_name String + contact_2_email_address String + contact_2_phone String +} +model Location { + id Int @id @default(autoincrement()) + case Case[] + contact_2_email_address String + contact_2_phone String + address String + AnalysisInput AnalysisInput[] +} + model CaseUser { - case Case @relation(fields: [caseId], references: [id], onDelete: Cascade, onUpdate: Cascade) - user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: Cascade) - caseId Int @id @default(autoincrement()) - userId String - @@unique([caseId, userId]) + case AnalysisInput @relation(fields: [analysisInputId], references: [id], onDelete: Cascade, onUpdate: Cascade) + user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: Cascade) + analysisInputId Int @id @default(autoincrement()) + userId String + @@unique([analysisInputId, userId]) } \ No newline at end of file From 01f30a19702f8e0aa3a45b61ddee6a437f54b062 Mon Sep 17 00:00:00 2001 From: Ethan Strominger Date: Fri, 4 Oct 2024 13:00:06 -0400 Subject: [PATCH 10/26] Remigrate scripts to have two clean scripts --- .../migration.sql | 35 -------- .../migration.sql | 8 -- .../migration.sql | 78 ------------------ .../migration.sql | 82 ++++--------------- 4 files changed, 14 insertions(+), 189 deletions(-) delete mode 100644 heat-stack/prisma/migrations/20240930173652_added_contacts_and_made_summary_output_case_id_unique/migration.sql delete mode 100644 heat-stack/prisma/migrations/20240930174229_required_case_user_case_id_user_id_combination_to_be_unique/migration.sql rename heat-stack/prisma/migrations/{20240926155816_added_case_user_association_table => 20241004165437_before_heat_schema_changes}/migration.sql (64%) rename heat-stack/prisma/migrations/{20241004163840_changed_models_to_reflect_erd => 20241004165803_initial_erd}/migration.sql (58%) diff --git a/heat-stack/prisma/migrations/20240930173652_added_contacts_and_made_summary_output_case_id_unique/migration.sql b/heat-stack/prisma/migrations/20240930173652_added_contacts_and_made_summary_output_case_id_unique/migration.sql deleted file mode 100644 index d92e6000..00000000 --- a/heat-stack/prisma/migrations/20240930173652_added_contacts_and_made_summary_output_case_id_unique/migration.sql +++ /dev/null @@ -1,35 +0,0 @@ -/* - Warnings: - - - A unique constraint covering the columns `[caseId]` on the table `SummaryOutput` will be added. If there are existing duplicate values, this will fail. - - Added the required column `contact_1_email_address` to the `Home` table without a default value. This is not possible if the table is not empty. - - Added the required column `contact_1_name` to the `Home` table without a default value. This is not possible if the table is not empty. - - Added the required column `contact_1_phone` to the `Home` table without a default value. This is not possible if the table is not empty. - - Added the required column `contact_2_email_address` to the `Home` table without a default value. This is not possible if the table is not empty. - - Added the required column `contact_2_name` to the `Home` table without a default value. This is not possible if the table is not empty. - - Added the required column `contact_2_phone` to the `Home` table without a default value. This is not possible if the table is not empty. - -*/ --- RedefineTables -PRAGMA defer_foreign_keys=ON; -PRAGMA foreign_keys=OFF; -CREATE TABLE "new_Home" ( - "id" TEXT NOT NULL PRIMARY KEY, - "name" TEXT NOT NULL, - "contact_1_name" TEXT NOT NULL, - "contact_1_email_address" TEXT NOT NULL, - "contact_1_phone" TEXT NOT NULL, - "contact_2_name" TEXT NOT NULL, - "contact_2_email_address" TEXT NOT NULL, - "contact_2_phone" TEXT NOT NULL, - "address" TEXT NOT NULL, - "livingArea" REAL NOT NULL -); -INSERT INTO "new_Home" ("address", "id", "livingArea", "name") SELECT "address", "id", "livingArea", "name" FROM "Home"; -DROP TABLE "Home"; -ALTER TABLE "new_Home" RENAME TO "Home"; -PRAGMA foreign_keys=ON; -PRAGMA defer_foreign_keys=OFF; - --- CreateIndex -CREATE UNIQUE INDEX "SummaryOutput_caseId_key" ON "SummaryOutput"("caseId"); diff --git a/heat-stack/prisma/migrations/20240930174229_required_case_user_case_id_user_id_combination_to_be_unique/migration.sql b/heat-stack/prisma/migrations/20240930174229_required_case_user_case_id_user_id_combination_to_be_unique/migration.sql deleted file mode 100644 index 3fc1b083..00000000 --- a/heat-stack/prisma/migrations/20240930174229_required_case_user_case_id_user_id_combination_to_be_unique/migration.sql +++ /dev/null @@ -1,8 +0,0 @@ -/* - Warnings: - - - A unique constraint covering the columns `[caseId,userId]` on the table `CaseUser` will be added. If there are existing duplicate values, this will fail. - -*/ --- CreateIndex -CREATE UNIQUE INDEX "CaseUser_caseId_userId_key" ON "CaseUser"("caseId", "userId"); diff --git a/heat-stack/prisma/migrations/20240926155816_added_case_user_association_table/migration.sql b/heat-stack/prisma/migrations/20241004165437_before_heat_schema_changes/migration.sql similarity index 64% rename from heat-stack/prisma/migrations/20240926155816_added_case_user_association_table/migration.sql rename to heat-stack/prisma/migrations/20241004165437_before_heat_schema_changes/migration.sql index 76bca36b..fbce1a0e 100644 --- a/heat-stack/prisma/migrations/20240926155816_added_case_user_association_table/migration.sql +++ b/heat-stack/prisma/migrations/20241004165437_before_heat_schema_changes/migration.sql @@ -105,81 +105,6 @@ CREATE TABLE "Connection" ( CONSTRAINT "Connection_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE ); --- CreateTable -CREATE TABLE "Home" ( - "id" TEXT NOT NULL PRIMARY KEY, - "name" TEXT NOT NULL, - "address" TEXT NOT NULL, - "livingArea" REAL NOT NULL -); - --- CreateTable -CREATE TABLE "Case" ( - "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "homeId" TEXT NOT NULL, - "summaryOutputId" TEXT NOT NULL, - "fuelType" TEXT NOT NULL, - "designTemperatureOverride" BOOLEAN NOT NULL, - "heatingSystemEfficiency" INTEGER NOT NULL, - "thermostatSetPoint" INTEGER NOT NULL, - "setbackTemperature" INTEGER NOT NULL, - "setbackHoursPerDay" INTEGER NOT NULL, - "numberOfOccupants" INTEGER NOT NULL, - "estimatedWaterHeatingEfficiency" INTEGER NOT NULL, - "standByLosses" INTEGER NOT NULL, - CONSTRAINT "Case_homeId_fkey" FOREIGN KEY ("homeId") REFERENCES "Home" ("id") ON DELETE CASCADE ON UPDATE CASCADE -); - --- CreateTable -CREATE TABLE "File" ( - "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "caseId" INTEGER NOT NULL, - "filePath" TEXT NOT NULL, - "description" TEXT NOT NULL, - CONSTRAINT "File_caseId_fkey" FOREIGN KEY ("caseId") REFERENCES "Case" ("id") ON DELETE CASCADE ON UPDATE CASCADE -); - --- CreateTable -CREATE TABLE "BillingPeriod" ( - "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "caseId" INTEGER NOT NULL, - "periodStartDate" DATETIME NOT NULL, - "periodEndDate" DATETIME NOT NULL, - "usage" REAL NOT NULL, - "analysisTypeOverride" BOOLEAN NOT NULL, - "inclusionOverride" BOOLEAN NOT NULL, - "originalAnalysisType" INTEGER NOT NULL, - "analysisType" INTEGER NOT NULL, - "defaultInclusionByCalculation" BOOLEAN NOT NULL, - "eliminatedAsOutlier" BOOLEAN NOT NULL, - "wholeHomeHeatLossRate" REAL NOT NULL, - CONSTRAINT "BillingPeriod_caseId_fkey" FOREIGN KEY ("caseId") REFERENCES "Case" ("id") ON DELETE CASCADE ON UPDATE CASCADE -); - --- CreateTable -CREATE TABLE "SummaryOutput" ( - "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "caseId" INTEGER NOT NULL, - "estimatedBalancePoint" REAL NOT NULL, - "otherFuelUsage" REAL NOT NULL, - "averageIndoorTemperature" REAL NOT NULL, - "differenceBetweenTiAndTbp" REAL NOT NULL, - "designTemperature" REAL NOT NULL, - "wholeHomeHeatLossRate" REAL NOT NULL, - "standardDeviationOfHeatLossRate" REAL NOT NULL, - "averageHeatLoad" REAL NOT NULL, - "maximumHeatLoad" REAL NOT NULL, - CONSTRAINT "SummaryOutput_caseId_fkey" FOREIGN KEY ("caseId") REFERENCES "Case" ("id") ON DELETE CASCADE ON UPDATE CASCADE -); - --- CreateTable -CREATE TABLE "CaseUser" ( - "caseId" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "userId" TEXT NOT NULL, - CONSTRAINT "CaseUser_caseId_fkey" FOREIGN KEY ("caseId") REFERENCES "Case" ("id") ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT "CaseUser_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE -); - -- CreateTable CREATE TABLE "_PermissionToRole" ( "A" TEXT NOT NULL, @@ -232,9 +157,6 @@ CREATE UNIQUE INDEX "Verification_target_type_key" ON "Verification"("target", " -- CreateIndex CREATE UNIQUE INDEX "Connection_providerName_providerId_key" ON "Connection"("providerName", "providerId"); --- CreateIndex -CREATE UNIQUE INDEX "Case_summaryOutputId_key" ON "Case"("summaryOutputId"); - -- CreateIndex CREATE UNIQUE INDEX "_PermissionToRole_AB_unique" ON "_PermissionToRole"("A", "B"); diff --git a/heat-stack/prisma/migrations/20241004163840_changed_models_to_reflect_erd/migration.sql b/heat-stack/prisma/migrations/20241004165803_initial_erd/migration.sql similarity index 58% rename from heat-stack/prisma/migrations/20241004163840_changed_models_to_reflect_erd/migration.sql rename to heat-stack/prisma/migrations/20241004165803_initial_erd/migration.sql index a28b9c50..77db1db8 100644 --- a/heat-stack/prisma/migrations/20241004163840_changed_models_to_reflect_erd/migration.sql +++ b/heat-stack/prisma/migrations/20241004165803_initial_erd/migration.sql @@ -1,51 +1,3 @@ -/* - Warnings: - - - You are about to drop the `BillingPeriod` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `File` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `Home` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the `SummaryOutput` table. If the table is not empty, all the data it contains will be lost. - - You are about to drop the column `designTemperatureOverride` on the `Case` table. All the data in the column will be lost. - - You are about to drop the column `estimatedWaterHeatingEfficiency` on the `Case` table. All the data in the column will be lost. - - You are about to drop the column `fuelType` on the `Case` table. All the data in the column will be lost. - - You are about to drop the column `heatingSystemEfficiency` on the `Case` table. All the data in the column will be lost. - - You are about to drop the column `homeId` on the `Case` table. All the data in the column will be lost. - - You are about to drop the column `numberOfOccupants` on the `Case` table. All the data in the column will be lost. - - You are about to drop the column `setbackHoursPerDay` on the `Case` table. All the data in the column will be lost. - - You are about to drop the column `setbackTemperature` on the `Case` table. All the data in the column will be lost. - - You are about to drop the column `standByLosses` on the `Case` table. All the data in the column will be lost. - - You are about to drop the column `summaryOutputId` on the `Case` table. All the data in the column will be lost. - - You are about to drop the column `thermostatSetPoint` on the `Case` table. All the data in the column will be lost. - - The primary key for the `CaseUser` table will be changed. If it partially fails, the table could be left without primary key constraint. - - You are about to drop the column `caseId` on the `CaseUser` table. All the data in the column will be lost. - - Added the required column `homeOwnerId` to the `Case` table without a default value. This is not possible if the table is not empty. - - Added the required column `locationId` to the `Case` table without a default value. This is not possible if the table is not empty. - - Added the required column `analysisInputId` to the `CaseUser` table without a default value. This is not possible if the table is not empty. - -*/ --- DropIndex -DROP INDEX "SummaryOutput_caseId_key"; - --- DropTable -PRAGMA foreign_keys=off; -DROP TABLE "BillingPeriod"; -PRAGMA foreign_keys=on; - --- DropTable -PRAGMA foreign_keys=off; -DROP TABLE "File"; -PRAGMA foreign_keys=on; - --- DropTable -PRAGMA foreign_keys=off; -DROP TABLE "Home"; -PRAGMA foreign_keys=on; - --- DropTable -PRAGMA foreign_keys=off; -DROP TABLE "SummaryOutput"; -PRAGMA foreign_keys=on; - -- CreateTable CREATE TABLE "AnalysisInput" ( "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, @@ -114,6 +66,15 @@ CREATE TABLE "AnalysisInputEnergyDataFile" ( CONSTRAINT "AnalysisInputEnergyDataFile_energyDataFileId_fkey" FOREIGN KEY ("energyDataFileId") REFERENCES "EnergyDataFile" ("id") ON DELETE CASCADE ON UPDATE CASCADE ); +-- CreateTable +CREATE TABLE "Case" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "homeOwnerId" INTEGER NOT NULL, + "locationId" INTEGER NOT NULL, + CONSTRAINT "Case_homeOwnerId_fkey" FOREIGN KEY ("homeOwnerId") REFERENCES "HomeOwner" ("id") ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT "Case_locationId_fkey" FOREIGN KEY ("locationId") REFERENCES "Location" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); + -- CreateTable CREATE TABLE "HomeOwner" ( "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, @@ -134,34 +95,19 @@ CREATE TABLE "Location" ( "address" TEXT NOT NULL ); --- RedefineTables -PRAGMA defer_foreign_keys=ON; -PRAGMA foreign_keys=OFF; -CREATE TABLE "new_Case" ( - "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - "homeOwnerId" INTEGER NOT NULL, - "locationId" INTEGER NOT NULL, - CONSTRAINT "Case_homeOwnerId_fkey" FOREIGN KEY ("homeOwnerId") REFERENCES "HomeOwner" ("id") ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT "Case_locationId_fkey" FOREIGN KEY ("locationId") REFERENCES "Location" ("id") ON DELETE CASCADE ON UPDATE CASCADE -); -INSERT INTO "new_Case" ("id") SELECT "id" FROM "Case"; -DROP TABLE "Case"; -ALTER TABLE "new_Case" RENAME TO "Case"; -CREATE TABLE "new_CaseUser" ( +-- CreateTable +CREATE TABLE "CaseUser" ( "analysisInputId" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "userId" TEXT NOT NULL, CONSTRAINT "CaseUser_analysisInputId_fkey" FOREIGN KEY ("analysisInputId") REFERENCES "AnalysisInput" ("id") ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT "CaseUser_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE ); -INSERT INTO "new_CaseUser" ("userId") SELECT "userId" FROM "CaseUser"; -DROP TABLE "CaseUser"; -ALTER TABLE "new_CaseUser" RENAME TO "CaseUser"; -CREATE UNIQUE INDEX "CaseUser_analysisInputId_userId_key" ON "CaseUser"("analysisInputId", "userId"); -PRAGMA foreign_keys=ON; -PRAGMA defer_foreign_keys=OFF; -- CreateIndex CREATE UNIQUE INDEX "AnalysisInput_summaryOutputId_key" ON "AnalysisInput"("summaryOutputId"); -- CreateIndex CREATE UNIQUE INDEX "AnalysisInputEnergyDataFile_analysisInputId_energyDataFileId_key" ON "AnalysisInputEnergyDataFile"("analysisInputId", "energyDataFileId"); + +-- CreateIndex +CREATE UNIQUE INDEX "CaseUser_analysisInputId_userId_key" ON "CaseUser"("analysisInputId", "userId"); From 95d9b0a0d948c592a430a97fa7754d7fc5faccac Mon Sep 17 00:00:00 2001 From: Ethan Strominger Date: Fri, 4 Oct 2024 13:02:08 -0400 Subject: [PATCH 11/26] Add comment to schema.prisma --- heat-stack/prisma/schema.prisma | 1 + 1 file changed, 1 insertion(+) diff --git a/heat-stack/prisma/schema.prisma b/heat-stack/prisma/schema.prisma index 96fbe623..dbe4e79c 100644 --- a/heat-stack/prisma/schema.prisma +++ b/heat-stack/prisma/schema.prisma @@ -12,6 +12,7 @@ datasource db { model User { id String @id @default(cuid()) + // caseUser added when CaseUser model added for HEAT schema caseUser CaseUser[] email String @unique From 33c8670a7a8856270f84f27f0671bda6199fa9a7 Mon Sep 17 00:00:00 2001 From: Vlad Korolev Date: Sun, 8 Sep 2024 17:05:35 -0400 Subject: [PATCH 12/26] Add test files --- .../merlin/Eversource_Green_Button.csv | 16 ++ .../merlin/Eversource_Green_Button.xml | 253 ++++++++++++++++++ 2 files changed, 269 insertions(+) create mode 100644 rules-engine/tests/test_rules_engine/cases/examples/natural_gas/merlin/Eversource_Green_Button.csv create mode 100644 rules-engine/tests/test_rules_engine/cases/examples/natural_gas/merlin/Eversource_Green_Button.xml diff --git a/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/merlin/Eversource_Green_Button.csv b/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/merlin/Eversource_Green_Button.csv new file mode 100644 index 00000000..7f43f5cf --- /dev/null +++ b/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/merlin/Eversource_Green_Button.csv @@ -0,0 +1,16 @@ +1 MAIN STREET BOSTON MA US 01234-5678 ,,,,,, +Data from 8/31/2023 to 7/1/2024,,,,,, +Requested By bob on 7/27/2024,,,,,, +Meter No: ,22945690,,,,, +,,,,,, +Account,Read Date,Usage,Number of Days,Usage per day,Charge,Average Temperature +73218880816,7/1/2024,-56,31,-1.81,$10.00 ,73 +73218880816,5/31/2024,-244,31,-7.87,$10.00 ,61 +73218880816,3/29/2024,254,30,8.47,$92.88 ,0 +73218880816,2/28/2024,571,29,19.69,$196.32 ,0 +73218880816,1/30/2024,1030,32,32.19,$344.85 ,0 +73218880816,12/29/2023,838,30,27.93,$229.18 ,0 +73218880816,11/29/2023,702,29,24.21,$193.59 ,0 +73218880816,10/31/2023,450,28,16.07,$127.70 ,0 +73218880816,10/3/2023,233,33,7.06,$70.94 ,0 +73218880816,8/31/2023,57,30,1.9,$24.91 ,0 diff --git a/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/merlin/Eversource_Green_Button.xml b/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/merlin/Eversource_Green_Button.xml new file mode 100644 index 00000000..7510b199 --- /dev/null +++ b/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/merlin/Eversource_Green_Button.xml @@ -0,0 +1,253 @@ + + urn:uuid:046638c0-8701-2342-9d80-0800200c8a23 + + ThirdPartyX Batch Feed + 2024-07-27T06:53:27 + + + + + + + 1 + + + urn:uuid:046638c0-8701-2342-9d80-0800200c8a23 + + + + + + 2024-07-27T06:53:27 + 1 Main Street Boston MA US 01234-5678, + 2024-07-27T06:53:27 + + + + + + urn:uuid:046638c0-8701-2342-9d80-0800200c8a23 + + + + + 2024-07-27T06:53:27 + 2024-07-27T06:53:27 + + + + + + 2592000 + 1722092007.25295 + + + 2491000 + + 0 + + + 2592000 + 1722092007.25295 + + 57000 + + + + + 2851200 + 1722092007.25295 + + + 7094000 + + 0 + + + 2851200 + 1722092007.25295 + + 233000 + + + + + 2419200 + 1722092007.25295 + + + 12770000 + + 0 + + + 2419200 + 1722092007.25295 + + 450000 + + + + + 2505600 + 1722092007.25295 + + + 19359000 + + 0 + + + 2505600 + 1722092007.25295 + + 702000 + + + + + 2592000 + 1722092007.25295 + + + 22918000 + + 0 + + + 2592000 + 1722092007.25295 + + 838000 + + + + + 2764800 + 1722092007.25295 + + + 34485000 + + 0 + + + 2764800 + 1722092007.25295 + + 1030000 + + + + + 2505600 + 1722092007.25295 + + + 19632000 + + 0 + + + 2505600 + 1722092007.25295 + + 571000 + + + + + 2592000 + 1722092007.25295 + + + 9288000 + + 0 + + + 2592000 + 1722092007.25295 + + 254000 + + + + + 2678400 + 1722092007.25295 + + + 1000000 + + 0 + + + 2678400 + 1722092007.25295 + + -244000 + + + + + 2678400 + 1722092007.25295 + + + 1000000 + + 0 + + + 2678400 + 1722092007.25295 + + -56000 + + + + urn:uuid:046638c0-8701-2342-9d80-0800200c8a23 + + + 2024-07-27T06:53:27 + + 2024-07-27T06:53:27 + + + + + + urn:uuid:046638c0-8701-2342-9d80-0800200c8a23 + + + 2024-07-27T06:53:27 + 2024-07-27T06:53:27 + + + + urn:uuid:046638c0-8701-2342-9d80-0800200c8a23 + + + 2024-07-27T06:53:27 + Usage Summary + 2024-07-27T06:53:27 + + + + + B40E2000 + 3600 + 360E2000 + 18000 + + + urn:uuid:046638c0-8701-2342-9d80-0800200c8a23 + + + 2024-07-27T06:53:27 + DST For North America + 2024-07-27T06:53:27 + + \ No newline at end of file From 1083acdf4766b404e9c207a38b9e15ba129f0270 Mon Sep 17 00:00:00 2001 From: AdamFinkle <77808710+AdamFinkle@users.noreply.github.com> Date: Tue, 20 Aug 2024 20:15:29 -0400 Subject: [PATCH 13/26] Added experimental XML parsing. --- rules-engine/requirements.txt | 1 + rules-engine/src/rules_engine/parser.py | 19 ++++ .../cases/parsing/xml/abridged/gas_direct.xml | 107 ++++++++++++++++++ .../tests/test_rules_engine/test_parser.py | 29 +++++ 4 files changed, 156 insertions(+) create mode 100644 rules-engine/tests/test_rules_engine/cases/parsing/xml/abridged/gas_direct.xml diff --git a/rules-engine/requirements.txt b/rules-engine/requirements.txt index 2afeaaa2..8fa60f51 100644 --- a/rules-engine/requirements.txt +++ b/rules-engine/requirements.txt @@ -14,3 +14,4 @@ typing-extensions==4.8.0 # via # pydantic # pydantic-core +greenbutton_objects @ git+https://github.com/codeforboston/greenbutton_objects@main diff --git a/rules-engine/src/rules_engine/parser.py b/rules-engine/src/rules_engine/parser.py index 006b8a27..8a8bf9ad 100644 --- a/rules-engine/src/rules_engine/parser.py +++ b/rules-engine/src/rules_engine/parser.py @@ -10,6 +10,7 @@ from enum import StrEnum from .pydantic_models import NaturalGasBillingInput, NaturalGasBillingRecordInput +from greenbutton_objects import parse class NaturalGasCompany(StrEnum): @@ -87,6 +88,24 @@ def _detect_gas_company(data: str) -> NaturalGasCompany: ) +def parse_gas_bill_xml(data_file: str) -> NaturalGasBillingInput: + bill = parse.parse_feed(str(data_file)) + records = [] + for meter_reading in bill.usage_points[0].meter_readings: + for interval_reading in meter_reading.readings: + records.append( + NaturalGasBillingRecordInput( + period_start_date = datetime.utcfromtimestamp(interval_reading.time_period.start).date(), + period_end_date = datetime.utcfromtimestamp(interval_reading.time_period.start + interval_reading.time_period.duration).date(), + usage_therms = interval_reading.value, + inclusion_override = None + ) + ) + return NaturalGasBillingInput(records=records) + + + + def parse_gas_bill( data: str, company: NaturalGasCompany | None = None ) -> NaturalGasBillingInput: diff --git a/rules-engine/tests/test_rules_engine/cases/parsing/xml/abridged/gas_direct.xml b/rules-engine/tests/test_rules_engine/cases/parsing/xml/abridged/gas_direct.xml new file mode 100644 index 00000000..d744a0a6 --- /dev/null +++ b/rules-engine/tests/test_rules_engine/cases/parsing/xml/abridged/gas_direct.xml @@ -0,0 +1,107 @@ + + + urn:uuid:5762c9e8-4e65-3b0c-83b3-7874683f3dbe + + + Opower ESPI Third Party Batch Feed v1 + 2024-06-21 + + urn:uuid:db678d4d-d9fe-3c0c-96f9-c13142c295e1 + + + + + 1 MAIN ST, ANYTOWN ME 12345 + 2024-06-21 + 2011-11-30T12:00:00.000Z + + + + 1 + + + + + + urn:uuid:cb36cc47-2cfb-3e47-abb9-7866f42cc194 + + + + + + + 2024-06-21 + 2011-11-30T12:00:00.000Z + + + + + + + urn:uuid:e7c7cd10-5e47-3d9c-8684-bd9e7eb401d3 + + + 2024-06-21 + 2011-11-30T12:00:00.000Z + + + 840 + -3 + 169 + + + + + urn:uuid:1efd2ba9-8c1a-3937-b7c0-ae55733e9e5e + + + + + + 92102400 + 1622005200 + + + 5100000 + + 3024000 + 1621987200 + + 37000 + + + 2493000 + + 2419200 + 1625011200 + + 14000 + + + 3281000 + + 2592000 + 1627430400 + + 21000 + + + 4207000 + + 2851200 + 1630022400 + + 27000 + + + 5543000 + + 2332800 + 1632873600 + + 41000 + + + + + diff --git a/rules-engine/tests/test_rules_engine/test_parser.py b/rules-engine/tests/test_rules_engine/test_parser.py index 6b9ee2df..598e72cf 100644 --- a/rules-engine/tests/test_rules_engine/test_parser.py +++ b/rules-engine/tests/test_rules_engine/test_parser.py @@ -23,6 +23,12 @@ def _read_gas_bill_national_grid() -> str: return f.read() +def _read_gas_bill_xml() -> str: + """Read a test natural gas bill from a test National Grid CSV""" + # TODO: Pass the file as a string rather than passing the file name + return ROOT_DIR.parent / "parsing" / "xml" / "abridged" / "gas_direct.xml" + + def _validate_eversource(result): """Validate the result of reading an Eversource CSV.""" assert len(result.records) == 36 @@ -57,6 +63,23 @@ def _validate_national_grid(result): assert second_row.inclusion_override == None +def _validate_xml_natural_gas(result): + """Validate the result of reading a National Grid CSV.""" + assert len(result.records) == 5 + for row in result.records: + assert isinstance(row, NaturalGasBillingRecordInput) + + # input: Natural gas billing,11/5/2020,12/3/2020,36,therms,$65.60 , + # from excel: 11/6/2020,12/3/2020,28,36,,1,1.29,0.99 + + second_row = result.records[1] + assert second_row.period_start_date == date(2021, 6, 30) + assert second_row.period_end_date == date(2021, 7, 28) + assert isinstance(second_row.usage_therms, float) + assert second_row.usage_therms == 14 + assert second_row.inclusion_override == None + + def test_parse_gas_bill(): """ Tests the logic of parse_gas_bill. @@ -87,6 +110,12 @@ def test_parse_gas_bill_national_grid(): ) +def test_parse_xml_natural_gas(): + _validate_xml_natural_gas( + parser.parse_gas_bill_xml(_read_gas_bill_xml()) + ) + + def test_detect_natural_gas_company(): """Tests if the natural gas company is correctly detected from the parsed csv.""" read_eversource = _read_gas_bill_eversource() From f5bffa2c522b86192a8eed807a5fca56739a309f Mon Sep 17 00:00:00 2001 From: Vlad Korolev Date: Tue, 3 Sep 2024 21:22:15 -0400 Subject: [PATCH 14/26] WIP saving progress Saving work --- rules-engine/src/rules_engine/parser.py | 6 +++--- rules-engine/src/rules_engine/pydantic_models.py | 6 +++--- rules-engine/tests/test_rules_engine/test_engine.py | 2 +- rules-engine/tests/test_rules_engine/test_utils.py | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/rules-engine/src/rules_engine/parser.py b/rules-engine/src/rules_engine/parser.py index 8a8bf9ad..7afe0ced 100644 --- a/rules-engine/src/rules_engine/parser.py +++ b/rules-engine/src/rules_engine/parser.py @@ -92,11 +92,11 @@ def parse_gas_bill_xml(data_file: str) -> NaturalGasBillingInput: bill = parse.parse_feed(str(data_file)) records = [] for meter_reading in bill.usage_points[0].meter_readings: - for interval_reading in meter_reading.readings: + for interval_reading in meter_reading.interval_readings: records.append( NaturalGasBillingRecordInput( - period_start_date = datetime.utcfromtimestamp(interval_reading.time_period.start).date(), - period_end_date = datetime.utcfromtimestamp(interval_reading.time_period.start + interval_reading.time_period.duration).date(), + period_start = interval_reading.time_period.start, # datetime.utcfromtimestamp(interval_reading.time_period.start).date(), + period_end = interval_reading.time_period.start + interval_reading.time_period.duration, # datetime.utcfromtimestamp(interval_reading.time_period.start + interval_reading.time_period.duration).date(), usage_therms = interval_reading.value, inclusion_override = None ) diff --git a/rules-engine/src/rules_engine/pydantic_models.py b/rules-engine/src/rules_engine/pydantic_models.py index fce42087..85842d44 100644 --- a/rules-engine/src/rules_engine/pydantic_models.py +++ b/rules-engine/src/rules_engine/pydantic_models.py @@ -3,7 +3,7 @@ """ from dataclasses import dataclass -from datetime import date, datetime +from datetime import datetime from enum import Enum from functools import cached_property from typing import Annotated, Any, Literal, Optional, Sequence @@ -97,8 +97,8 @@ class OilPropaneBillingInput(BaseModel): class NaturalGasBillingRecordInput(BaseModel): """From Natural Gas tab. A single row of the Billing input table.""" - period_start_date: datetime = Field(description="Natural Gas!A") - period_end_date: datetime = Field(description="Natural Gas!B") + period_start: datetime = Field(description="Natural Gas!A") + period_end: datetime = Field(description="Natural Gas!B") usage_therms: float = Field(description="Natural Gas!D") inclusion_override: Optional[bool] = Field(description="Natural Gas!E") diff --git a/rules-engine/tests/test_rules_engine/test_engine.py b/rules-engine/tests/test_rules_engine/test_engine.py index 40ca3346..97c4a24b 100644 --- a/rules-engine/tests/test_rules_engine/test_engine.py +++ b/rules-engine/tests/test_rules_engine/test_engine.py @@ -1,4 +1,4 @@ -from datetime import date, datetime +from datetime import datetime from typing import Any import pytest diff --git a/rules-engine/tests/test_rules_engine/test_utils.py b/rules-engine/tests/test_rules_engine/test_utils.py index 32a6c81b..1ce50aa5 100644 --- a/rules-engine/tests/test_rules_engine/test_utils.py +++ b/rules-engine/tests/test_rules_engine/test_utils.py @@ -1,5 +1,5 @@ import csv -from datetime import date, datetime, timedelta +from datetime import datetime, timedelta, date from pathlib import Path from typing import Any, Sequence From 0e7cfc5ba1ee047d313242f4aaa8ca2dc4712795 Mon Sep 17 00:00:00 2001 From: Ethan Strominger Date: Tue, 22 Oct 2024 20:23:00 -0400 Subject: [PATCH 15/26] Rename directory --- {rules-engine => python}/.gitignore | 0 {rules-engine => python}/Makefile | 0 {rules-engine => python}/README.md | 0 {rules-engine => python}/pyproject.toml | 0 {rules-engine => python}/requirements-dev.txt | 0 {rules-engine => python}/requirements.txt | 0 .../src/data/merged_structure_temps.csv | 0 .../src/rules_engine/__init__.py | 0 .../src/rules_engine/engine.py | 0 .../src/rules_engine/helpers.py | 0 .../src/rules_engine/parser.py | 0 .../src/rules_engine/pydantic_models.py | 0 python/src/rules_engine/refactor.md | 166 ++++++++++++++++++ .../tests/test_rules_engine/__init__.py | 0 .../cases/examples/README.md | 0 .../cowen/Heat Load Analysis Beta 7.xlsx | Bin .../examples/fuel_oil/cowen/oil-propane.csv | 0 .../examples/fuel_oil/cowen/summary.json | 0 .../example-2/Heat Load Analysis Beta 7.xlsx | Bin .../fuel_oil/example-2/oil-propane.csv | 0 .../examples/fuel_oil/example-2/summary.json | 0 .../gelfand/Heat Load Analysis Beta 7.xlsx | Bin .../examples/fuel_oil/gelfand/oil-propane.csv | 0 .../examples/fuel_oil/gelfand/summary.json | 0 .../harris/Heat Load Analysis Beta 7.xlsx | Bin .../examples/fuel_oil/harris/oil-propane.csv | 0 .../examples/fuel_oil/harris/summary.json | 0 .../karle/Heat Load Analysis Beta 7.xlsx | Bin .../examples/fuel_oil/karle/oil-propane.csv | 0 .../examples/fuel_oil/karle/summary.json | 0 .../breslow/Heat Load Analysis Beta 7.xlsx | Bin .../natural_gas/breslow/natural-gas.csv | 0 .../examples/natural_gas/breslow/summary.json | 0 .../cali/Heat Load Analysis Beta 7.xlsx | Bin .../examples/natural_gas/cali/natural-gas.csv | 0 .../examples/natural_gas/cali/summary.json | 0 .../example-1/Heat Load Analysis Beta 7.xlsx | Bin .../natural_gas/example-1/natural-gas.csv | 0 .../natural_gas/example-1/summary.json | 0 .../example-4/Heat Load Analysis Beta 7.xlsx | Bin .../natural_gas/example-4/natural-gas.csv | 0 .../natural_gas/example-4/summary.json | 0 .../feldman/Heat Load Analysis Beta 7.xlsx | Bin .../feldman/natural-gas-eversource.csv | 0 .../natural_gas/feldman/natural-gas.csv | 0 .../examples/natural_gas/feldman/summary.json | 0 .../lewitus/Heat Load Analysis Beta 7.xlsx | Bin .../natural_gas/lewitus/natural-gas.csv | 0 .../examples/natural_gas/lewitus/summary.json | 0 .../quateman/Heat Load Analysis Beta 7.xlsx | Bin .../quateman/natural-gas-national-grid.csv | 0 .../natural_gas/quateman/natural-gas.csv | 0 .../natural_gas/quateman/summary.json | 0 .../shen/Heat Load Analysis Beta 7.xlsx | Bin .../examples/natural_gas/shen/natural-gas.csv | 0 .../examples/natural_gas/shen/summary.json | 0 .../vitti/Heat Load Analysis Beta 7.xlsx | Bin .../natural_gas/vitti/natural-gas.csv | 0 .../examples/natural_gas/vitti/summary.json | 0 .../yellepeddi/Heat Load Analysis Beta 7.xlsx | Bin .../natural_gas/yellepeddi/natural-gas.csv | 0 .../natural_gas/yellepeddi/summary.json | 0 .../cases/examples/temperature-data.csv | 0 .../generate_example_data.py | 0 .../tests/test_rules_engine/test-res.json | 0 .../tests/test_rules_engine/test_engine.py | 0 .../tests/test_rules_engine/test_fuel_oil.py | 0 .../test_rules_engine/test_natural_gas.py | 0 .../tests/test_rules_engine/test_parser.py | 0 .../test_rules_engine/test_pydantic_models.py | 0 .../tests/test_rules_engine/test_utils.py | 0 71 files changed, 166 insertions(+) rename {rules-engine => python}/.gitignore (100%) rename {rules-engine => python}/Makefile (100%) rename {rules-engine => python}/README.md (100%) rename {rules-engine => python}/pyproject.toml (100%) rename {rules-engine => python}/requirements-dev.txt (100%) rename {rules-engine => python}/requirements.txt (100%) rename {rules-engine => python}/src/data/merged_structure_temps.csv (100%) rename {rules-engine => python}/src/rules_engine/__init__.py (100%) rename {rules-engine => python}/src/rules_engine/engine.py (100%) rename {rules-engine => python}/src/rules_engine/helpers.py (100%) rename {rules-engine => python}/src/rules_engine/parser.py (100%) rename {rules-engine => python}/src/rules_engine/pydantic_models.py (100%) create mode 100644 python/src/rules_engine/refactor.md rename {rules-engine => python}/tests/test_rules_engine/__init__.py (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/README.md (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/fuel_oil/cowen/Heat Load Analysis Beta 7.xlsx (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/fuel_oil/cowen/oil-propane.csv (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/fuel_oil/cowen/summary.json (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/fuel_oil/example-2/Heat Load Analysis Beta 7.xlsx (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/fuel_oil/example-2/oil-propane.csv (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/fuel_oil/example-2/summary.json (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/fuel_oil/gelfand/Heat Load Analysis Beta 7.xlsx (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/fuel_oil/gelfand/oil-propane.csv (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/fuel_oil/gelfand/summary.json (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/fuel_oil/harris/Heat Load Analysis Beta 7.xlsx (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/fuel_oil/harris/oil-propane.csv (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/fuel_oil/harris/summary.json (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/fuel_oil/karle/Heat Load Analysis Beta 7.xlsx (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/fuel_oil/karle/oil-propane.csv (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/fuel_oil/karle/summary.json (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/natural_gas/breslow/Heat Load Analysis Beta 7.xlsx (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/natural_gas/breslow/natural-gas.csv (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/natural_gas/breslow/summary.json (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/natural_gas/cali/Heat Load Analysis Beta 7.xlsx (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/natural_gas/cali/natural-gas.csv (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/natural_gas/cali/summary.json (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/natural_gas/example-1/Heat Load Analysis Beta 7.xlsx (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/natural_gas/example-1/natural-gas.csv (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/natural_gas/example-1/summary.json (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/natural_gas/example-4/Heat Load Analysis Beta 7.xlsx (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/natural_gas/example-4/natural-gas.csv (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/natural_gas/example-4/summary.json (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/natural_gas/feldman/Heat Load Analysis Beta 7.xlsx (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/natural_gas/feldman/natural-gas-eversource.csv (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/natural_gas/feldman/natural-gas.csv (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/natural_gas/feldman/summary.json (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/natural_gas/lewitus/Heat Load Analysis Beta 7.xlsx (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/natural_gas/lewitus/natural-gas.csv (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/natural_gas/lewitus/summary.json (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/natural_gas/quateman/Heat Load Analysis Beta 7.xlsx (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/natural_gas/quateman/natural-gas-national-grid.csv (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/natural_gas/quateman/natural-gas.csv (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/natural_gas/quateman/summary.json (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/natural_gas/shen/Heat Load Analysis Beta 7.xlsx (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/natural_gas/shen/natural-gas.csv (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/natural_gas/shen/summary.json (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/natural_gas/vitti/Heat Load Analysis Beta 7.xlsx (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/natural_gas/vitti/natural-gas.csv (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/natural_gas/vitti/summary.json (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/natural_gas/yellepeddi/Heat Load Analysis Beta 7.xlsx (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/natural_gas/yellepeddi/natural-gas.csv (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/natural_gas/yellepeddi/summary.json (100%) rename {rules-engine => python}/tests/test_rules_engine/cases/examples/temperature-data.csv (100%) rename {rules-engine => python}/tests/test_rules_engine/generate_example_data.py (100%) rename {rules-engine => python}/tests/test_rules_engine/test-res.json (100%) rename {rules-engine => python}/tests/test_rules_engine/test_engine.py (100%) rename {rules-engine => python}/tests/test_rules_engine/test_fuel_oil.py (100%) rename {rules-engine => python}/tests/test_rules_engine/test_natural_gas.py (100%) rename {rules-engine => python}/tests/test_rules_engine/test_parser.py (100%) rename {rules-engine => python}/tests/test_rules_engine/test_pydantic_models.py (100%) rename {rules-engine => python}/tests/test_rules_engine/test_utils.py (100%) diff --git a/rules-engine/.gitignore b/python/.gitignore similarity index 100% rename from rules-engine/.gitignore rename to python/.gitignore diff --git a/rules-engine/Makefile b/python/Makefile similarity index 100% rename from rules-engine/Makefile rename to python/Makefile diff --git a/rules-engine/README.md b/python/README.md similarity index 100% rename from rules-engine/README.md rename to python/README.md diff --git a/rules-engine/pyproject.toml b/python/pyproject.toml similarity index 100% rename from rules-engine/pyproject.toml rename to python/pyproject.toml diff --git a/rules-engine/requirements-dev.txt b/python/requirements-dev.txt similarity index 100% rename from rules-engine/requirements-dev.txt rename to python/requirements-dev.txt diff --git a/rules-engine/requirements.txt b/python/requirements.txt similarity index 100% rename from rules-engine/requirements.txt rename to python/requirements.txt diff --git a/rules-engine/src/data/merged_structure_temps.csv b/python/src/data/merged_structure_temps.csv similarity index 100% rename from rules-engine/src/data/merged_structure_temps.csv rename to python/src/data/merged_structure_temps.csv diff --git a/rules-engine/src/rules_engine/__init__.py b/python/src/rules_engine/__init__.py similarity index 100% rename from rules-engine/src/rules_engine/__init__.py rename to python/src/rules_engine/__init__.py diff --git a/rules-engine/src/rules_engine/engine.py b/python/src/rules_engine/engine.py similarity index 100% rename from rules-engine/src/rules_engine/engine.py rename to python/src/rules_engine/engine.py diff --git a/rules-engine/src/rules_engine/helpers.py b/python/src/rules_engine/helpers.py similarity index 100% rename from rules-engine/src/rules_engine/helpers.py rename to python/src/rules_engine/helpers.py diff --git a/rules-engine/src/rules_engine/parser.py b/python/src/rules_engine/parser.py similarity index 100% rename from rules-engine/src/rules_engine/parser.py rename to python/src/rules_engine/parser.py diff --git a/rules-engine/src/rules_engine/pydantic_models.py b/python/src/rules_engine/pydantic_models.py similarity index 100% rename from rules-engine/src/rules_engine/pydantic_models.py rename to python/src/rules_engine/pydantic_models.py diff --git a/python/src/rules_engine/refactor.md b/python/src/rules_engine/refactor.md new file mode 100644 index 00000000..a103f0e5 --- /dev/null +++ b/python/src/rules_engine/refactor.md @@ -0,0 +1,166 @@ +Qs: +- stand_by_losses + +home variables used +``` + avg_ua + balance_point + non_heating_usage + stdev_pct + balance_point_graph +``` + +1. Remove temporary_rules_engine.py +2. Rename rules-engine to "python" +3. Rename NormalizedBillingRecordBase class to BillingInput +4. Rename BillingPeriod to ProcessedBill and billing_period to processed_bill +5. Combine get_outputs_normalized and convert_to_intermediate_billing_record and get rid of NormalizedBillingRecord. There is only one place NormalizedBillingRecord is used and combining code +gets rid of the need for the class. +- Change +``` + billing_periods: list[NormalizedBillingPeriodRecordBase] = [] + + for input_val in natural_gas_billing_input.records: + billing_periods.append( + NormalizedBillingPeriodRecordBase( + period_start_date=input_val.period_start_date, + period_end_date=input_val.period_end_date, + usage=input_val.usage_therms, + inclusion_override=bool(input_val.inclusion_override), + ) + ) + + return get_outputs_normalized( + summary_input, None, temperature_input, billing_periods + ) + + def get_outputs_normalized + loops through billing_periods and does a bunch of stuff + +``` +to +``` + inputBill = + NormalizedBillingPeriodRecordBase( + period_start_date=input_val.period_start_date, + period_end_date=input_val.period_end_date, + usage=input_val.usage_therms, + analysis_type_override=input_val.inclusion_override, + inclusion_override=True, + ) + ) + avg_temps = derive_avg_temps(temparature_input) + default_analysis_type = derive_default_analysis_type + ( fuel_type, + inputBill.start_date, + inputBill.end_date + ) + processedBill = ProcessedBill( + input = inputBill, + avg_temps = avg_temps, + default_analysis_type = default_analysis_type + // usage not needed, it is part of inputBill + ) +``` +6. Home - Call home.calculate from home.init or move the code from home.init into home.calculate. Otherwise, the fact that Home.init does calculations is hidden. Code looks like this: +``` +home=Home(args) # does some calculations +home.calculate() # does some calculations +``` +This would change to either +``` +home=Home(args) +``` +or +``` +home=Home.calculate(args) +``` +7. Home - change to functional programming paradigm where you provide inputs and outputs + - Change + `_calculate_avg_summer_usage()` => `avg_summer_usage = _get_avg_summer_usage(summer_bills)` + - Change + `_calculate_avg_non_heating_usage ()` => +to +``` +avg_non_heating_usage = _get_avg_non_heating_usage ( + fuel_type, + avg_summer_usage, + dhw_input.estimated_water_heating_efficiency, + dhw_input.number_of_occupants, + stand_by_losses, + heating_system_efficiency +) +``` +================== +- change +`for billing_period in billing_periods ...` => +to +``` +for billing_period in billing_periods + { bills_summer, bills_winter, bills_shoulder } + =_categorize_bills_by_season (billing_periods) +``` +================== +- Change +``` +calculate_dhw_usage() +``` +to +``` + dhw_usage = _calculate_dhw_usage ( + estimated_water_heating_efficiency, + dhw_input.number_of_occupants, + stand_by_losses, + heating_system_efficiency + ) +``` +================== +- Change +`self.initialize_ua(billing_period)` => `_set_ua(billing_period,avg_non_heating_usage)` + +- Change?? Parameters are never set +``` +def calculate( + self, + initial_balance_point_sensitivity: float = 0.5, + stdev_pct_max: float = 0.10, + max_stdev_pct_diff: float = 0.01, + next_balance_point_sensitivity: float = 0.5, + ) +``` +=> +``` +def calculate ( + + initial_balance_point_sensitivity: float = 0.5, + stdev_pct_max: float = 0.10, + max_stdev_pct_diff: float = 0.01, + next_balance_point_sensitivity: float = 0.5, +``` +================== +- calculate method +`self._calculate_avg_non_heating_usage` - duplicated. Remove one of the calls +================== + +- Change +``` +self._calculate_balance_point_and_ua( + initial_balance_point_sensitivity, + stdev_pct_max, + max_stdev_pct_diff, + next_balance_point_sensitivity, + ) +``` => +``` +{ balance_point, stdev_pct + balance_point_graph } = + _get_graph (initial_balance_point_sensitivity, + stdev_pct_max, + max_stdev_pct_diff, + next_balance_point_sensitivity, + bills_winter) +``` +================== + + + diff --git a/rules-engine/tests/test_rules_engine/__init__.py b/python/tests/test_rules_engine/__init__.py similarity index 100% rename from rules-engine/tests/test_rules_engine/__init__.py rename to python/tests/test_rules_engine/__init__.py diff --git a/rules-engine/tests/test_rules_engine/cases/examples/README.md b/python/tests/test_rules_engine/cases/examples/README.md similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/README.md rename to python/tests/test_rules_engine/cases/examples/README.md diff --git a/rules-engine/tests/test_rules_engine/cases/examples/fuel_oil/cowen/Heat Load Analysis Beta 7.xlsx b/python/tests/test_rules_engine/cases/examples/fuel_oil/cowen/Heat Load Analysis Beta 7.xlsx similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/fuel_oil/cowen/Heat Load Analysis Beta 7.xlsx rename to python/tests/test_rules_engine/cases/examples/fuel_oil/cowen/Heat Load Analysis Beta 7.xlsx diff --git a/rules-engine/tests/test_rules_engine/cases/examples/fuel_oil/cowen/oil-propane.csv b/python/tests/test_rules_engine/cases/examples/fuel_oil/cowen/oil-propane.csv similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/fuel_oil/cowen/oil-propane.csv rename to python/tests/test_rules_engine/cases/examples/fuel_oil/cowen/oil-propane.csv diff --git a/rules-engine/tests/test_rules_engine/cases/examples/fuel_oil/cowen/summary.json b/python/tests/test_rules_engine/cases/examples/fuel_oil/cowen/summary.json similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/fuel_oil/cowen/summary.json rename to python/tests/test_rules_engine/cases/examples/fuel_oil/cowen/summary.json diff --git a/rules-engine/tests/test_rules_engine/cases/examples/fuel_oil/example-2/Heat Load Analysis Beta 7.xlsx b/python/tests/test_rules_engine/cases/examples/fuel_oil/example-2/Heat Load Analysis Beta 7.xlsx similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/fuel_oil/example-2/Heat Load Analysis Beta 7.xlsx rename to python/tests/test_rules_engine/cases/examples/fuel_oil/example-2/Heat Load Analysis Beta 7.xlsx diff --git a/rules-engine/tests/test_rules_engine/cases/examples/fuel_oil/example-2/oil-propane.csv b/python/tests/test_rules_engine/cases/examples/fuel_oil/example-2/oil-propane.csv similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/fuel_oil/example-2/oil-propane.csv rename to python/tests/test_rules_engine/cases/examples/fuel_oil/example-2/oil-propane.csv diff --git a/rules-engine/tests/test_rules_engine/cases/examples/fuel_oil/example-2/summary.json b/python/tests/test_rules_engine/cases/examples/fuel_oil/example-2/summary.json similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/fuel_oil/example-2/summary.json rename to python/tests/test_rules_engine/cases/examples/fuel_oil/example-2/summary.json diff --git a/rules-engine/tests/test_rules_engine/cases/examples/fuel_oil/gelfand/Heat Load Analysis Beta 7.xlsx b/python/tests/test_rules_engine/cases/examples/fuel_oil/gelfand/Heat Load Analysis Beta 7.xlsx similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/fuel_oil/gelfand/Heat Load Analysis Beta 7.xlsx rename to python/tests/test_rules_engine/cases/examples/fuel_oil/gelfand/Heat Load Analysis Beta 7.xlsx diff --git a/rules-engine/tests/test_rules_engine/cases/examples/fuel_oil/gelfand/oil-propane.csv b/python/tests/test_rules_engine/cases/examples/fuel_oil/gelfand/oil-propane.csv similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/fuel_oil/gelfand/oil-propane.csv rename to python/tests/test_rules_engine/cases/examples/fuel_oil/gelfand/oil-propane.csv diff --git a/rules-engine/tests/test_rules_engine/cases/examples/fuel_oil/gelfand/summary.json b/python/tests/test_rules_engine/cases/examples/fuel_oil/gelfand/summary.json similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/fuel_oil/gelfand/summary.json rename to python/tests/test_rules_engine/cases/examples/fuel_oil/gelfand/summary.json diff --git a/rules-engine/tests/test_rules_engine/cases/examples/fuel_oil/harris/Heat Load Analysis Beta 7.xlsx b/python/tests/test_rules_engine/cases/examples/fuel_oil/harris/Heat Load Analysis Beta 7.xlsx similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/fuel_oil/harris/Heat Load Analysis Beta 7.xlsx rename to python/tests/test_rules_engine/cases/examples/fuel_oil/harris/Heat Load Analysis Beta 7.xlsx diff --git a/rules-engine/tests/test_rules_engine/cases/examples/fuel_oil/harris/oil-propane.csv b/python/tests/test_rules_engine/cases/examples/fuel_oil/harris/oil-propane.csv similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/fuel_oil/harris/oil-propane.csv rename to python/tests/test_rules_engine/cases/examples/fuel_oil/harris/oil-propane.csv diff --git a/rules-engine/tests/test_rules_engine/cases/examples/fuel_oil/harris/summary.json b/python/tests/test_rules_engine/cases/examples/fuel_oil/harris/summary.json similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/fuel_oil/harris/summary.json rename to python/tests/test_rules_engine/cases/examples/fuel_oil/harris/summary.json diff --git a/rules-engine/tests/test_rules_engine/cases/examples/fuel_oil/karle/Heat Load Analysis Beta 7.xlsx b/python/tests/test_rules_engine/cases/examples/fuel_oil/karle/Heat Load Analysis Beta 7.xlsx similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/fuel_oil/karle/Heat Load Analysis Beta 7.xlsx rename to python/tests/test_rules_engine/cases/examples/fuel_oil/karle/Heat Load Analysis Beta 7.xlsx diff --git a/rules-engine/tests/test_rules_engine/cases/examples/fuel_oil/karle/oil-propane.csv b/python/tests/test_rules_engine/cases/examples/fuel_oil/karle/oil-propane.csv similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/fuel_oil/karle/oil-propane.csv rename to python/tests/test_rules_engine/cases/examples/fuel_oil/karle/oil-propane.csv diff --git a/rules-engine/tests/test_rules_engine/cases/examples/fuel_oil/karle/summary.json b/python/tests/test_rules_engine/cases/examples/fuel_oil/karle/summary.json similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/fuel_oil/karle/summary.json rename to python/tests/test_rules_engine/cases/examples/fuel_oil/karle/summary.json diff --git a/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/breslow/Heat Load Analysis Beta 7.xlsx b/python/tests/test_rules_engine/cases/examples/natural_gas/breslow/Heat Load Analysis Beta 7.xlsx similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/natural_gas/breslow/Heat Load Analysis Beta 7.xlsx rename to python/tests/test_rules_engine/cases/examples/natural_gas/breslow/Heat Load Analysis Beta 7.xlsx diff --git a/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/breslow/natural-gas.csv b/python/tests/test_rules_engine/cases/examples/natural_gas/breslow/natural-gas.csv similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/natural_gas/breslow/natural-gas.csv rename to python/tests/test_rules_engine/cases/examples/natural_gas/breslow/natural-gas.csv diff --git a/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/breslow/summary.json b/python/tests/test_rules_engine/cases/examples/natural_gas/breslow/summary.json similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/natural_gas/breslow/summary.json rename to python/tests/test_rules_engine/cases/examples/natural_gas/breslow/summary.json diff --git a/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/cali/Heat Load Analysis Beta 7.xlsx b/python/tests/test_rules_engine/cases/examples/natural_gas/cali/Heat Load Analysis Beta 7.xlsx similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/natural_gas/cali/Heat Load Analysis Beta 7.xlsx rename to python/tests/test_rules_engine/cases/examples/natural_gas/cali/Heat Load Analysis Beta 7.xlsx diff --git a/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/cali/natural-gas.csv b/python/tests/test_rules_engine/cases/examples/natural_gas/cali/natural-gas.csv similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/natural_gas/cali/natural-gas.csv rename to python/tests/test_rules_engine/cases/examples/natural_gas/cali/natural-gas.csv diff --git a/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/cali/summary.json b/python/tests/test_rules_engine/cases/examples/natural_gas/cali/summary.json similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/natural_gas/cali/summary.json rename to python/tests/test_rules_engine/cases/examples/natural_gas/cali/summary.json diff --git a/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/example-1/Heat Load Analysis Beta 7.xlsx b/python/tests/test_rules_engine/cases/examples/natural_gas/example-1/Heat Load Analysis Beta 7.xlsx similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/natural_gas/example-1/Heat Load Analysis Beta 7.xlsx rename to python/tests/test_rules_engine/cases/examples/natural_gas/example-1/Heat Load Analysis Beta 7.xlsx diff --git a/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/example-1/natural-gas.csv b/python/tests/test_rules_engine/cases/examples/natural_gas/example-1/natural-gas.csv similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/natural_gas/example-1/natural-gas.csv rename to python/tests/test_rules_engine/cases/examples/natural_gas/example-1/natural-gas.csv diff --git a/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/example-1/summary.json b/python/tests/test_rules_engine/cases/examples/natural_gas/example-1/summary.json similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/natural_gas/example-1/summary.json rename to python/tests/test_rules_engine/cases/examples/natural_gas/example-1/summary.json diff --git a/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/example-4/Heat Load Analysis Beta 7.xlsx b/python/tests/test_rules_engine/cases/examples/natural_gas/example-4/Heat Load Analysis Beta 7.xlsx similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/natural_gas/example-4/Heat Load Analysis Beta 7.xlsx rename to python/tests/test_rules_engine/cases/examples/natural_gas/example-4/Heat Load Analysis Beta 7.xlsx diff --git a/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/example-4/natural-gas.csv b/python/tests/test_rules_engine/cases/examples/natural_gas/example-4/natural-gas.csv similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/natural_gas/example-4/natural-gas.csv rename to python/tests/test_rules_engine/cases/examples/natural_gas/example-4/natural-gas.csv diff --git a/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/example-4/summary.json b/python/tests/test_rules_engine/cases/examples/natural_gas/example-4/summary.json similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/natural_gas/example-4/summary.json rename to python/tests/test_rules_engine/cases/examples/natural_gas/example-4/summary.json diff --git a/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/feldman/Heat Load Analysis Beta 7.xlsx b/python/tests/test_rules_engine/cases/examples/natural_gas/feldman/Heat Load Analysis Beta 7.xlsx similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/natural_gas/feldman/Heat Load Analysis Beta 7.xlsx rename to python/tests/test_rules_engine/cases/examples/natural_gas/feldman/Heat Load Analysis Beta 7.xlsx diff --git a/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/feldman/natural-gas-eversource.csv b/python/tests/test_rules_engine/cases/examples/natural_gas/feldman/natural-gas-eversource.csv similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/natural_gas/feldman/natural-gas-eversource.csv rename to python/tests/test_rules_engine/cases/examples/natural_gas/feldman/natural-gas-eversource.csv diff --git a/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/feldman/natural-gas.csv b/python/tests/test_rules_engine/cases/examples/natural_gas/feldman/natural-gas.csv similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/natural_gas/feldman/natural-gas.csv rename to python/tests/test_rules_engine/cases/examples/natural_gas/feldman/natural-gas.csv diff --git a/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/feldman/summary.json b/python/tests/test_rules_engine/cases/examples/natural_gas/feldman/summary.json similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/natural_gas/feldman/summary.json rename to python/tests/test_rules_engine/cases/examples/natural_gas/feldman/summary.json diff --git a/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/lewitus/Heat Load Analysis Beta 7.xlsx b/python/tests/test_rules_engine/cases/examples/natural_gas/lewitus/Heat Load Analysis Beta 7.xlsx similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/natural_gas/lewitus/Heat Load Analysis Beta 7.xlsx rename to python/tests/test_rules_engine/cases/examples/natural_gas/lewitus/Heat Load Analysis Beta 7.xlsx diff --git a/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/lewitus/natural-gas.csv b/python/tests/test_rules_engine/cases/examples/natural_gas/lewitus/natural-gas.csv similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/natural_gas/lewitus/natural-gas.csv rename to python/tests/test_rules_engine/cases/examples/natural_gas/lewitus/natural-gas.csv diff --git a/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/lewitus/summary.json b/python/tests/test_rules_engine/cases/examples/natural_gas/lewitus/summary.json similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/natural_gas/lewitus/summary.json rename to python/tests/test_rules_engine/cases/examples/natural_gas/lewitus/summary.json diff --git a/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/quateman/Heat Load Analysis Beta 7.xlsx b/python/tests/test_rules_engine/cases/examples/natural_gas/quateman/Heat Load Analysis Beta 7.xlsx similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/natural_gas/quateman/Heat Load Analysis Beta 7.xlsx rename to python/tests/test_rules_engine/cases/examples/natural_gas/quateman/Heat Load Analysis Beta 7.xlsx diff --git a/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/quateman/natural-gas-national-grid.csv b/python/tests/test_rules_engine/cases/examples/natural_gas/quateman/natural-gas-national-grid.csv similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/natural_gas/quateman/natural-gas-national-grid.csv rename to python/tests/test_rules_engine/cases/examples/natural_gas/quateman/natural-gas-national-grid.csv diff --git a/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/quateman/natural-gas.csv b/python/tests/test_rules_engine/cases/examples/natural_gas/quateman/natural-gas.csv similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/natural_gas/quateman/natural-gas.csv rename to python/tests/test_rules_engine/cases/examples/natural_gas/quateman/natural-gas.csv diff --git a/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/quateman/summary.json b/python/tests/test_rules_engine/cases/examples/natural_gas/quateman/summary.json similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/natural_gas/quateman/summary.json rename to python/tests/test_rules_engine/cases/examples/natural_gas/quateman/summary.json diff --git a/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/shen/Heat Load Analysis Beta 7.xlsx b/python/tests/test_rules_engine/cases/examples/natural_gas/shen/Heat Load Analysis Beta 7.xlsx similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/natural_gas/shen/Heat Load Analysis Beta 7.xlsx rename to python/tests/test_rules_engine/cases/examples/natural_gas/shen/Heat Load Analysis Beta 7.xlsx diff --git a/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/shen/natural-gas.csv b/python/tests/test_rules_engine/cases/examples/natural_gas/shen/natural-gas.csv similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/natural_gas/shen/natural-gas.csv rename to python/tests/test_rules_engine/cases/examples/natural_gas/shen/natural-gas.csv diff --git a/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/shen/summary.json b/python/tests/test_rules_engine/cases/examples/natural_gas/shen/summary.json similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/natural_gas/shen/summary.json rename to python/tests/test_rules_engine/cases/examples/natural_gas/shen/summary.json diff --git a/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/vitti/Heat Load Analysis Beta 7.xlsx b/python/tests/test_rules_engine/cases/examples/natural_gas/vitti/Heat Load Analysis Beta 7.xlsx similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/natural_gas/vitti/Heat Load Analysis Beta 7.xlsx rename to python/tests/test_rules_engine/cases/examples/natural_gas/vitti/Heat Load Analysis Beta 7.xlsx diff --git a/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/vitti/natural-gas.csv b/python/tests/test_rules_engine/cases/examples/natural_gas/vitti/natural-gas.csv similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/natural_gas/vitti/natural-gas.csv rename to python/tests/test_rules_engine/cases/examples/natural_gas/vitti/natural-gas.csv diff --git a/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/vitti/summary.json b/python/tests/test_rules_engine/cases/examples/natural_gas/vitti/summary.json similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/natural_gas/vitti/summary.json rename to python/tests/test_rules_engine/cases/examples/natural_gas/vitti/summary.json diff --git a/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/yellepeddi/Heat Load Analysis Beta 7.xlsx b/python/tests/test_rules_engine/cases/examples/natural_gas/yellepeddi/Heat Load Analysis Beta 7.xlsx similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/natural_gas/yellepeddi/Heat Load Analysis Beta 7.xlsx rename to python/tests/test_rules_engine/cases/examples/natural_gas/yellepeddi/Heat Load Analysis Beta 7.xlsx diff --git a/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/yellepeddi/natural-gas.csv b/python/tests/test_rules_engine/cases/examples/natural_gas/yellepeddi/natural-gas.csv similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/natural_gas/yellepeddi/natural-gas.csv rename to python/tests/test_rules_engine/cases/examples/natural_gas/yellepeddi/natural-gas.csv diff --git a/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/yellepeddi/summary.json b/python/tests/test_rules_engine/cases/examples/natural_gas/yellepeddi/summary.json similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/natural_gas/yellepeddi/summary.json rename to python/tests/test_rules_engine/cases/examples/natural_gas/yellepeddi/summary.json diff --git a/rules-engine/tests/test_rules_engine/cases/examples/temperature-data.csv b/python/tests/test_rules_engine/cases/examples/temperature-data.csv similarity index 100% rename from rules-engine/tests/test_rules_engine/cases/examples/temperature-data.csv rename to python/tests/test_rules_engine/cases/examples/temperature-data.csv diff --git a/rules-engine/tests/test_rules_engine/generate_example_data.py b/python/tests/test_rules_engine/generate_example_data.py similarity index 100% rename from rules-engine/tests/test_rules_engine/generate_example_data.py rename to python/tests/test_rules_engine/generate_example_data.py diff --git a/rules-engine/tests/test_rules_engine/test-res.json b/python/tests/test_rules_engine/test-res.json similarity index 100% rename from rules-engine/tests/test_rules_engine/test-res.json rename to python/tests/test_rules_engine/test-res.json diff --git a/rules-engine/tests/test_rules_engine/test_engine.py b/python/tests/test_rules_engine/test_engine.py similarity index 100% rename from rules-engine/tests/test_rules_engine/test_engine.py rename to python/tests/test_rules_engine/test_engine.py diff --git a/rules-engine/tests/test_rules_engine/test_fuel_oil.py b/python/tests/test_rules_engine/test_fuel_oil.py similarity index 100% rename from rules-engine/tests/test_rules_engine/test_fuel_oil.py rename to python/tests/test_rules_engine/test_fuel_oil.py diff --git a/rules-engine/tests/test_rules_engine/test_natural_gas.py b/python/tests/test_rules_engine/test_natural_gas.py similarity index 100% rename from rules-engine/tests/test_rules_engine/test_natural_gas.py rename to python/tests/test_rules_engine/test_natural_gas.py diff --git a/rules-engine/tests/test_rules_engine/test_parser.py b/python/tests/test_rules_engine/test_parser.py similarity index 100% rename from rules-engine/tests/test_rules_engine/test_parser.py rename to python/tests/test_rules_engine/test_parser.py diff --git a/rules-engine/tests/test_rules_engine/test_pydantic_models.py b/python/tests/test_rules_engine/test_pydantic_models.py similarity index 100% rename from rules-engine/tests/test_rules_engine/test_pydantic_models.py rename to python/tests/test_rules_engine/test_pydantic_models.py diff --git a/rules-engine/tests/test_rules_engine/test_utils.py b/python/tests/test_rules_engine/test_utils.py similarity index 100% rename from rules-engine/tests/test_rules_engine/test_utils.py rename to python/tests/test_rules_engine/test_utils.py From afe06533b3b3b73c5cea0fe834ea2993942a269b Mon Sep 17 00:00:00 2001 From: Ethan Strominger Date: Tue, 22 Oct 2024 20:39:24 -0400 Subject: [PATCH 16/26] Rename rules-engine to python --- .github/workflows/heat-stack.yml | 2 +- .vscode/settings.json | 2 +- README.md | 2 +- heat-stack/app/root_original.tsx | 2 +- heat-stack/app/routes/_heat+/single.tsx | 2 +- heat-stack/app/utils/pyodide.test.ts | 30 ++++++++++++------------- heat-stack/package.json | 4 ++-- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/.github/workflows/heat-stack.yml b/.github/workflows/heat-stack.yml index 2cdd20d5..4a552a8b 100644 --- a/.github/workflows/heat-stack.yml +++ b/.github/workflows/heat-stack.yml @@ -10,7 +10,7 @@ on: workflow_dispatch: env: - rules-engine-working-directory: rules-engine + rules-engine-working-directory: python heat-stack-working-directory: heat-stack defaults: diff --git a/.vscode/settings.json b/.vscode/settings.json index 09409736..34438b2b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,6 @@ { "python.testing.pytestArgs": [ - "rules-engine" + "python" ], "python.testing.unittestEnabled": false, "python.testing.pytestEnabled": true diff --git a/README.md b/README.md index ffdf3246..de19d2b5 100644 --- a/README.md +++ b/README.md @@ -29,4 +29,4 @@ To install the front end, see this [README.md](https://github.com/codeforboston/ ### Documentation For the Heat Stack (Javascript) portion read: [README.md](https://github.com/codeforboston/home-energy-analysis-tool/blob/main/heat-stack/README.md) -For the Rules Engine (Python) portion read: [README.md](https://github.com/codeforboston/home-energy-analysis-tool/blob/main/rules-engine/README.md) +For the Rules Engine (Python) portion read: [README.md](https://github.com/codeforboston/home-energy-analysis-tool/blob/main/python/README.md) diff --git a/heat-stack/app/root_original.tsx b/heat-stack/app/root_original.tsx index dab771ee..320ef5e8 100644 --- a/heat-stack/app/root_original.tsx +++ b/heat-stack/app/root_original.tsx @@ -64,7 +64,7 @@ // import type { Weather } from './WeatherExample.d.ts' // import * as pyodideModule from 'pyodide' -// import engine from '../../rules-engine/src/rules_engine/engine.py' +// import engine from '../../python/src/rules_engine/engine.py' // const getPyodide = async () => { // // public folder: diff --git a/heat-stack/app/routes/_heat+/single.tsx b/heat-stack/app/routes/_heat+/single.tsx index ce9fc1ca..93f62c31 100644 --- a/heat-stack/app/routes/_heat+/single.tsx +++ b/heat-stack/app/routes/_heat+/single.tsx @@ -161,7 +161,7 @@ export async function action({ request, params }: ActionFunctionArgs) { const pyodide: any = await getPyodide() return pyodide } - // consider running https://github.com/codeforboston/home-energy-analysis-tool/blob/main/rules-engine/tests/test_rules_engine/test_engine.py + // consider running https://github.com/codeforboston/home-energy-analysis-tool/blob/main/python/tests/test_rules_engine/test_engine.py const pyodide: any = await runPythonScript() ////////////////////// diff --git a/heat-stack/app/utils/pyodide.test.ts b/heat-stack/app/utils/pyodide.test.ts index 1dff3364..04c9e18b 100644 --- a/heat-stack/app/utils/pyodide.test.ts +++ b/heat-stack/app/utils/pyodide.test.ts @@ -6,7 +6,7 @@ import WeatherUtil from "#app/utils/WeatherUtil"; /* For this to pass, you must run - `pushd ../rules-engine && python3 -m venv venv && source venv/bin/activate && pip install -q build && python3 -m build && popd` */ + `pushd ../python && python3 -m venv venv && source venv/bin/activate && pip install -q build && python3 -m build && popd` */ /* Referenced https://github.com/epicweb-dev/full-stack-testing/blob/main/exercises/04.unit-test/02.solution.spies/app/utils/misc.error-message.test.ts of https://www.epicweb.dev/workshops/web-application-testing*/ // test('pyodide loads', async () => { @@ -60,12 +60,12 @@ import WeatherUtil from "#app/utils/WeatherUtil"; // // await micropip.install(['annotated-types']) // await pyodide.loadPackage( -// '../rules-engine/dist/rules_engine-0.0.1-py3-none-any.whl', +// '../python/dist/rules_engine-0.0.1-py3-none-any.whl', // ) // return pyodide // } -// // consider running https://github.com/codeforboston/home-energy-analysis-tool/blob/main/rules-engine/tests/test_rules_engine/test_engine.py +// // consider running https://github.com/codeforboston/home-energy-analysis-tool/blob/main/python/tests/test_rules_engine/test_engine.py // const pyodide: any = await runPythonScript() // const result = await pyodide.runPythonAsync(` // from rules_engine import engine @@ -127,19 +127,19 @@ test('pyodide solves climate change', async () => { // await micropip.install(['annotated-types']) await pyodide.loadPackage( - '../rules-engine/dist/rules_engine-0.0.1-py3-none-any.whl', + '../python/dist/rules_engine-0.0.1-py3-none-any.whl', ) return pyodide } - // consider running https://github.com/codeforboston/home-energy-analysis-tool/blob/main/rules-engine/tests/test_rules_engine/test_engine.py + // consider running https://github.com/codeforboston/home-energy-analysis-tool/blob/main/python/tests/test_rules_engine/test_engine.py const pyodide: any = await runPythonScript() const GU = new GeocodeUtil(); const WU = new WeatherUtil(); // 1) parser.parse_gas_bill(data: str, company: NaturalGasCompany) - // https://github.com/codeforboston/home-energy-analysis-tool/blob/main/rules-engine/src/rules_engine/parser.py#L60 + // https://github.com/codeforboston/home-energy-analysis-tool/blob/main/python/src/rules_engine/parser.py#L60 /* 2) get_outputs_natural_gas( summary_input: SummaryInput, @@ -147,12 +147,12 @@ test('pyodide solves climate change', async () => { natural_gas_billing_input: NaturalGasBillingInput, ) -> RulesEngineResult - https://github.com/codeforboston/home-energy-analysis-tool/blob/main/rules-engine/src/rules_engine/engine.py#L59 + https://github.com/codeforboston/home-energy-analysis-tool/blob/main/python/src/rules_engine/engine.py#L59 */ /** * TODO: - * - Match up our types with rules engine types at https://github.com/codeforboston/home-energy-analysis-tool/blob/main/rules-engine/src/rules_engine/pydantic_models.py#L57 + * - Match up our types with rules engine types at https://github.com/codeforboston/home-energy-analysis-tool/blob/main/python/src/rules_engine/pydantic_models.py#L57 * - Use those to create summary_input (in the same file) * - Use those to create temperature_input (in the same file) * - Use those to create natural_gas_billing_input (in the same file) @@ -169,7 +169,7 @@ test('pyodide solves climate change', async () => { console.log("weather data",TIWD); - // https://github.com/codeforboston/home-energy-analysis-tool/tree/main/rules-engine/tests/test_rules_engine/cases/examples/quateman + // https://github.com/codeforboston/home-energy-analysis-tool/tree/main/python/tests/test_rules_engine/cases/examples/quateman const exampleNationalGridCSV = `Name,FIRST LAST,,,,, Address,"100 STREET AVE, BOSTON MA 02130",,,,, Account Number,1111111111,,,,, @@ -337,19 +337,19 @@ test('pyodide solves climate change', async () => { // // await micropip.install(['annotated-types']) // await pyodide.loadPackage( -// '../rules-engine/dist/rules_engine-0.0.1-py3-none-any.whl', +// '../python/dist/rules_engine-0.0.1-py3-none-any.whl', // ) // return pyodide // } -// // consider running https://github.com/codeforboston/home-energy-analysis-tool/blob/main/rules-engine/tests/test_rules_engine/test_engine.py +// // consider running https://github.com/codeforboston/home-energy-analysis-tool/blob/main/python/tests/test_rules_engine/test_engine.py // const pyodide: any = await runPythonScript() // const GU = new GeocodeUtil(); // const WU = new WeatherUtil(); // // 1) parser.parse_gas_bill(data: str, company: NaturalGasCompany) -// // https://github.com/codeforboston/home-energy-analysis-tool/blob/main/rules-engine/src/rules_engine/parser.py#L60 +// // https://github.com/codeforboston/home-energy-analysis-tool/blob/main/python/src/rules_engine/parser.py#L60 // /* 2) get_outputs_natural_gas( // summary_input: SummaryInput, @@ -357,12 +357,12 @@ test('pyodide solves climate change', async () => { // natural_gas_billing_input: NaturalGasBillingInput, // ) -> RulesEngineResult -// https://github.com/codeforboston/home-energy-analysis-tool/blob/main/rules-engine/src/rules_engine/engine.py#L59 +// https://github.com/codeforboston/home-energy-analysis-tool/blob/main/python/src/rules_engine/engine.py#L59 // */ // /** // * TODO: -// * - Match up our types with rules engine types at https://github.com/codeforboston/home-energy-analysis-tool/blob/main/rules-engine/src/rules_engine/pydantic_models.py#L57 +// * - Match up our types with rules engine types at https://github.com/codeforboston/home-energy-analysis-tool/blob/main/python/src/rules_engine/pydantic_models.py#L57 // * - Use those to create summary_input (in the same file) // * - Use those to create temperature_input (in the same file) // * - Use those to create natural_gas_billing_input (in the same file) @@ -377,7 +377,7 @@ test('pyodide solves climate change', async () => { // const TIWD = await WU.getThatWeathaData(x, y, "2024-03-20", "2024-04-20"); // console.log("weather data",TIWD); -// // https://github.com/codeforboston/home-energy-analysis-tool/tree/main/rules-engine/tests/test_rules_engine/cases/examples/quateman +// // https://github.com/codeforboston/home-energy-analysis-tool/tree/main/python/tests/test_rules_engine/cases/examples/quateman // const exampleNationalGridCSV = `Name,FIRST LAST,,,,, // Address,"100 STREET AVE, BOSTON MA 02130",,,,, // Account Number,1111111111,,,,, diff --git a/heat-stack/package.json b/heat-stack/package.json index 4070435a..d599e8b6 100644 --- a/heat-stack/package.json +++ b/heat-stack/package.json @@ -21,8 +21,8 @@ "setup": "npm run build && prisma generate && prisma migrate deploy && prisma db seed && playwright install", "start": "cross-env NODE_ENV=production node .", "start:mocks": "cross-env NODE_ENV=production MOCKS=true tsx .", - "test": "cd ../rules-engine && python3 -m venv venv && . venv/bin/activate && pip install -q build && python3 -m build && cd ../heat-stack && vitest && rm -rf ../rules-engine/dist ", - "buildpy": "cd ../rules-engine && python3 -m venv venv && . venv/bin/activate && pip install -q build && python3 -m build && cp dist/rules_engine-0.0.1-py3-none-any.whl ../heat-stack/public/pyodide-env", + "test": "cd ../python && python3 -m venv venv && . venv/bin/activate && pip install -q build && python3 -m build && cd ../heat-stack && vitest && rm -rf ../python/dist ", + "buildpy": "cd ../python && python3 -m venv venv && . venv/bin/activate && pip install -q build && python3 -m build && cp dist/rules_engine-0.0.1-py3-none-any.whl ../heat-stack/public/pyodide-env", "coverage": "vitest run --coverage", "test:e2e": "npm run test:e2e:dev --silent", "test:e2e:dev": "playwright test --ui", From e3d822a5b76664803dc698052c4d8fea697073b9 Mon Sep 17 00:00:00 2001 From: Ethan Strominger Date: Fri, 25 Oct 2024 12:06:33 -0400 Subject: [PATCH 17/26] Co-authored-by: AdamFinkle Co-authored-by: Deb Debnath Co-authored-by: stemgene --- python/src/rules_engine/refactor.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/python/src/rules_engine/refactor.md b/python/src/rules_engine/refactor.md index a103f0e5..102260fc 100644 --- a/python/src/rules_engine/refactor.md +++ b/python/src/rules_engine/refactor.md @@ -9,11 +9,7 @@ home variables used stdev_pct balance_point_graph ``` - -1. Remove temporary_rules_engine.py -2. Rename rules-engine to "python" -3. Rename NormalizedBillingRecordBase class to BillingInput -4. Rename BillingPeriod to ProcessedBill and billing_period to processed_bill +1. Look at names of classes, match with erd 5. Combine get_outputs_normalized and convert_to_intermediate_billing_record and get rid of NormalizedBillingRecord. There is only one place NormalizedBillingRecord is used and combining code gets rid of the need for the class. - Change From 4ccc6594d59060efda3e9a85d9476d5b58c4f1e3 Mon Sep 17 00:00:00 2001 From: AdamFinkle <77808710+AdamFinkle@users.noreply.github.com> Date: Fri, 25 Oct 2024 13:58:03 -0400 Subject: [PATCH 18/26] Changed prisma to match newly-modified ERD. --- heat-stack/prisma/schema.prisma | 66 ++++++++++++++++----------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/heat-stack/prisma/schema.prisma b/heat-stack/prisma/schema.prisma index dbe4e79c..43edf827 100644 --- a/heat-stack/prisma/schema.prisma +++ b/heat-stack/prisma/schema.prisma @@ -172,16 +172,17 @@ model Connection { } // HEAT schema starts here -model AnalysisInput { +model Analysis { + id Int @id @default(autoincrement()) + case Case @relation(fields: [caseId], references: [id], onDelete: Cascade, onUpdate: Cascade) + caseId Int + heatingOutput HeatingOutput[] + analysisDataFile AnalysisDataFile[] +} + +model HeatingInput { id Int @id @default(autoincrement()) - location Location @relation(fields: [locationId], references: [id], onDelete: Cascade, onUpdate: Cascade) caseUser CaseUser[] - analysisOutput AnalysisOutput[] - analysisInputEnergyDataFile AnalysisInputEnergyDataFile[] - case Case @relation(fields: [caseId], references: [id], onDelete: Cascade, onUpdate: Cascade) - caseId Int - locationId Int - summaryOutputId String @unique fuelType String designTemperatureOverride Boolean heatingSystemEfficiency Int @@ -197,7 +198,7 @@ model AnalysisInput { model ProcessedEnergyBill { id Int @id @default(autoincrement()) - AnalysisInput AnalysisInput @relation(fields: [analysisInputId], references: [id], onDelete: Cascade, onUpdate: Cascade) + AnalysisInput HeatingInput @relation(fields: [analysisInputId], references: [id], onDelete: Cascade, onUpdate: Cascade) analysisInputId Int periodStartDate DateTime periodEndDate DateTime @@ -208,10 +209,10 @@ model ProcessedEnergyBill { inclusionOverride Boolean } -model AnalysisOutput { +model HeatingOutput { id Int @id @default(autoincrement()) - AnalysisInput AnalysisInput @relation(fields: [analysisInputId], references: [id], onDelete: Cascade, onUpdate: Cascade) - analysisInputId Int + analysis Analysis @relation(fields: [analysisId], references: [id], onDelete: Cascade, onUpdate: Cascade) + analysisId Int estimatedBalancePoint Float otherFuelUsage Float averageIndoorTemperature Float @@ -224,30 +225,30 @@ model AnalysisOutput { } model EnergyDataFile { - id Int @id @default(autoincrement()) - provider String - fuelType String - precedingDeliveryDate DateTime - filePath String - description String - AnalysisInputEnergyDataFile AnalysisInputEnergyDataFile[] + id Int @id @default(autoincrement()) + provider String + fuelType String + precedingDeliveryDate DateTime + filePath String + description String + analysisDataFile AnalysisDataFile[] } -model AnalysisInputEnergyDataFile { - analysisInput AnalysisInput @relation(fields: [analysisInputId], references: [id], onDelete: Cascade, onUpdate: Cascade) - analysisInputId Int +model AnalysisDataFile { + analysis Analysis @relation(fields: [analysisId], references: [id], onDelete: Cascade, onUpdate: Cascade) + analysisId Int EnergyDataFile EnergyDataFile @relation(fields: [energyDataFileId], references: [id], onDelete: Cascade, onUpdate: Cascade) energyDataFileId Int - @@unique([analysisInputId, energyDataFileId]) + @@unique([analysisId, energyDataFileId]) } model Case { - id Int @id @default(autoincrement()) - homeOwner HomeOwner @relation(fields: [homeOwnerId], references: [id], onDelete: Cascade, onUpdate: Cascade) - homeOwnerId Int - location Location @relation(fields: [locationId], references: [id], onDelete: Cascade, onUpdate: Cascade) - locationId Int - analysisInput AnalysisInput[] + id Int @id @default(autoincrement()) + homeOwner HomeOwner @relation(fields: [homeOwnerId], references: [id], onDelete: Cascade, onUpdate: Cascade) + homeOwnerId Int + location Location @relation(fields: [locationId], references: [id], onDelete: Cascade, onUpdate: Cascade) + locationId Int + analysis Analysis[] } model HomeOwner { @@ -267,13 +268,12 @@ model Location { contact_2_email_address String contact_2_phone String address String - AnalysisInput AnalysisInput[] } model CaseUser { - case AnalysisInput @relation(fields: [analysisInputId], references: [id], onDelete: Cascade, onUpdate: Cascade) + case HeatingInput @relation(fields: [analysisId], references: [id], onDelete: Cascade, onUpdate: Cascade) user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: Cascade) - analysisInputId Int @id @default(autoincrement()) + analysisId Int @id @default(autoincrement()) userId String - @@unique([analysisInputId, userId]) + @@unique([analysisId, userId]) } \ No newline at end of file From c15842c238d164db60494d287011df2ecbc88ae7 Mon Sep 17 00:00:00 2001 From: Ethan Strominger Date: Sat, 26 Oct 2024 10:28:07 -0400 Subject: [PATCH 19/26] Co-authored-by: AdamFinkle Co-authored-by: Deb Debnath Co-authored-by: stemgene --- heat-stack/package-lock.json | 144 ----------------------------------- heat-stack/package.json | 7 +- 2 files changed, 3 insertions(+), 148 deletions(-) diff --git a/heat-stack/package-lock.json b/heat-stack/package-lock.json index 01783033..6cf192c9 100644 --- a/heat-stack/package-lock.json +++ b/heat-stack/package-lock.json @@ -117,7 +117,6 @@ "prettier-plugin-tailwindcss": "^0.6.5", "prisma": "^5.19.1", "remix-flat-routes": "^0.6.5", - "ts-node": "^10.9.2", "tsx": "^4.16.2", "typescript": "^5.5.3", "vite": "^5.3.4", @@ -875,28 +874,6 @@ "zod": "^3.21.0" } }, - "node_modules/@cspotcode/source-map-support": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", - "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", - "dev": true, - "dependencies": { - "@jridgewell/trace-mapping": "0.3.9" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/@cspotcode/source-map-support/node_modules/@jridgewell/trace-mapping": { - "version": "0.3.9", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", - "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", - "dev": true, - "dependencies": { - "@jridgewell/resolve-uri": "^3.0.3", - "@jridgewell/sourcemap-codec": "^1.4.10" - } - }, "node_modules/@emotion/hash": { "version": "0.9.1", "resolved": "https://registry.npmjs.org/@emotion/hash/-/hash-0.9.1.tgz", @@ -6357,30 +6334,6 @@ "dev": true, "license": "MIT" }, - "node_modules/@tsconfig/node10": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz", - "integrity": "sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==", - "dev": true - }, - "node_modules/@tsconfig/node12": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", - "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", - "dev": true - }, - "node_modules/@tsconfig/node14": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", - "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", - "dev": true - }, - "node_modules/@tsconfig/node16": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", - "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", - "dev": true - }, "node_modules/@types/acorn": { "version": "4.0.6", "resolved": "https://registry.npmjs.org/@types/acorn/-/acorn-4.0.6.tgz", @@ -8160,18 +8113,6 @@ "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } }, - "node_modules/acorn-walk": { - "version": "8.3.4", - "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.4.tgz", - "integrity": "sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g==", - "dev": true, - "dependencies": { - "acorn": "^8.11.0" - }, - "engines": { - "node": ">=0.4.0" - } - }, "node_modules/address": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/address/-/address-2.0.3.tgz", @@ -9559,12 +9500,6 @@ } } }, - "node_modules/create-require": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", - "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", - "dev": true - }, "node_modules/cross-env": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", @@ -14114,12 +14049,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/make-error": { - "version": "1.3.6", - "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", - "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", - "dev": true - }, "node_modules/markdown-extensions": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/markdown-extensions/-/markdown-extensions-1.1.1.tgz", @@ -20176,64 +20105,6 @@ "integrity": "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==", "license": "Apache-2.0" }, - "node_modules/ts-node": { - "version": "10.9.2", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", - "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", - "dev": true, - "dependencies": { - "@cspotcode/source-map-support": "^0.8.0", - "@tsconfig/node10": "^1.0.7", - "@tsconfig/node12": "^1.0.7", - "@tsconfig/node14": "^1.0.0", - "@tsconfig/node16": "^1.0.2", - "acorn": "^8.4.1", - "acorn-walk": "^8.1.1", - "arg": "^4.1.0", - "create-require": "^1.1.0", - "diff": "^4.0.1", - "make-error": "^1.1.1", - "v8-compile-cache-lib": "^3.0.1", - "yn": "3.1.1" - }, - "bin": { - "ts-node": "dist/bin.js", - "ts-node-cwd": "dist/bin-cwd.js", - "ts-node-esm": "dist/bin-esm.js", - "ts-node-script": "dist/bin-script.js", - "ts-node-transpile-only": "dist/bin-transpile.js", - "ts-script": "dist/bin-script-deprecated.js" - }, - "peerDependencies": { - "@swc/core": ">=1.2.50", - "@swc/wasm": ">=1.2.50", - "@types/node": "*", - "typescript": ">=2.7" - }, - "peerDependenciesMeta": { - "@swc/core": { - "optional": true - }, - "@swc/wasm": { - "optional": true - } - } - }, - "node_modules/ts-node/node_modules/arg": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", - "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", - "dev": true - }, - "node_modules/ts-node/node_modules/diff": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", - "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", - "dev": true, - "engines": { - "node": ">=0.3.1" - } - }, "node_modules/tsconfig-paths": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-4.2.0.tgz", @@ -21402,12 +21273,6 @@ "node": ">=6" } }, - "node_modules/v8-compile-cache-lib": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", - "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", - "dev": true - }, "node_modules/validate-npm-package-license": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", @@ -22726,15 +22591,6 @@ "node": ">=8" } }, - "node_modules/yn": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", - "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", - "dev": true, - "engines": { - "node": ">=6" - } - }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", diff --git a/heat-stack/package.json b/heat-stack/package.json index 81a2352a..ec0d4c13 100644 --- a/heat-stack/package.json +++ b/heat-stack/package.json @@ -8,9 +8,6 @@ "#app/*": "./app/*", "#tests/*": "./tests/*" }, - "prisma": { - "seed": "ts-node ./prisma/seed.ts" - }, "scripts": { "build": "run-s build:*", "build:icons": "tsx ./other/build-icons.ts", @@ -155,7 +152,6 @@ "prettier-plugin-tailwindcss": "^0.6.5", "prisma": "^5.19.1", "remix-flat-routes": "^0.6.5", - "ts-node": "^10.9.2", "tsx": "^4.16.2", "typescript": "^5.5.3", "vite": "^5.3.4", @@ -167,5 +163,8 @@ "epic-stack": { "head": "b2f899fec54a76c1e0e863dadad6e9340af5ca1b", "date": "2024-08-15T23:19:44Z" + }, + "prisma": { + "seed": "tsx prisma/seed.ts" } } From 5c7d6101b828e1a71eaf62260a38e78617c0bfdc Mon Sep 17 00:00:00 2001 From: Ethan Strominger Date: Sat, 26 Oct 2024 10:35:05 -0400 Subject: [PATCH 20/26] Restore package.json, package-lock.json from HEAD~v2 to fix prisma issue --- .../migration.sql | 112 ++++++++++++++++++ 1 file changed, 112 insertions(+) rename heat-stack/prisma/migrations/{20241004165437_before_heat_schema_changes => 20241026143219_heat_schema_v1_wp_implementation}/migration.sql (51%) diff --git a/heat-stack/prisma/migrations/20241004165437_before_heat_schema_changes/migration.sql b/heat-stack/prisma/migrations/20241026143219_heat_schema_v1_wp_implementation/migration.sql similarity index 51% rename from heat-stack/prisma/migrations/20241004165437_before_heat_schema_changes/migration.sql rename to heat-stack/prisma/migrations/20241026143219_heat_schema_v1_wp_implementation/migration.sql index fbce1a0e..51943c55 100644 --- a/heat-stack/prisma/migrations/20241004165437_before_heat_schema_changes/migration.sql +++ b/heat-stack/prisma/migrations/20241026143219_heat_schema_v1_wp_implementation/migration.sql @@ -1,3 +1,35 @@ +/* + Warnings: + + - You are about to drop the `AnalysisInput` table. If the table is not empty, all the data it contains will be lost. + - You are about to drop the `AnalysisInputEnergyDataFile` table. If the table is not empty, all the data it contains will be lost. + - You are about to drop the `AnalysisOutput` table. If the table is not empty, all the data it contains will be lost. + - The primary key for the `CaseUser` table will be changed. If it partially fails, the table could be left without primary key constraint. + - You are about to drop the column `analysisInputId` on the `CaseUser` table. All the data in the column will be lost. + - Added the required column `analysisId` to the `CaseUser` table without a default value. This is not possible if the table is not empty. + +*/ +-- DropIndex +DROP INDEX "AnalysisInput_summaryOutputId_key"; + +-- DropIndex +DROP INDEX "AnalysisInputEnergyDataFile_analysisInputId_energyDataFileId_key"; + +-- DropTable +PRAGMA foreign_keys=off; +DROP TABLE "AnalysisInput"; +PRAGMA foreign_keys=on; + +-- DropTable +PRAGMA foreign_keys=off; +DROP TABLE "AnalysisInputEnergyDataFile"; +PRAGMA foreign_keys=on; + +-- DropTable +PRAGMA foreign_keys=off; +DROP TABLE "AnalysisOutput"; +PRAGMA foreign_keys=on; + -- CreateTable CREATE TABLE "User" ( "id" TEXT NOT NULL PRIMARY KEY, @@ -105,6 +137,52 @@ CREATE TABLE "Connection" ( CONSTRAINT "Connection_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE ); +-- CreateTable +CREATE TABLE "Analysis" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "caseId" INTEGER NOT NULL, + CONSTRAINT "Analysis_caseId_fkey" FOREIGN KEY ("caseId") REFERENCES "Case" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); + +-- CreateTable +CREATE TABLE "HeatingInput" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "fuelType" TEXT NOT NULL, + "designTemperatureOverride" BOOLEAN NOT NULL, + "heatingSystemEfficiency" INTEGER NOT NULL, + "thermostatSetPoint" INTEGER NOT NULL, + "setbackTemperature" INTEGER NOT NULL, + "setbackHoursPerDay" INTEGER NOT NULL, + "numberOfOccupants" INTEGER NOT NULL, + "estimatedWaterHeatingEfficiency" INTEGER NOT NULL, + "standByLosses" INTEGER NOT NULL, + "livingArea" REAL NOT NULL +); + +-- CreateTable +CREATE TABLE "HeatingOutput" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "analysisId" INTEGER NOT NULL, + "estimatedBalancePoint" REAL NOT NULL, + "otherFuelUsage" REAL NOT NULL, + "averageIndoorTemperature" REAL NOT NULL, + "differenceBetweenTiAndTbp" REAL NOT NULL, + "designTemperature" REAL NOT NULL, + "wholeHomeHeatLossRate" REAL NOT NULL, + "standardDeviationOfHeatLossRate" REAL NOT NULL, + "averageHeatLoad" REAL NOT NULL, + "maximumHeatLoad" REAL NOT NULL, + CONSTRAINT "HeatingOutput_analysisId_fkey" FOREIGN KEY ("analysisId") REFERENCES "Analysis" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); + +-- CreateTable +CREATE TABLE "AnalysisDataFile" ( + "analysisId" INTEGER NOT NULL, + "energyDataFileId" INTEGER NOT NULL, + CONSTRAINT "AnalysisDataFile_analysisId_fkey" FOREIGN KEY ("analysisId") REFERENCES "Analysis" ("id") ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT "AnalysisDataFile_energyDataFileId_fkey" FOREIGN KEY ("energyDataFileId") REFERENCES "EnergyDataFile" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); + -- CreateTable CREATE TABLE "_PermissionToRole" ( "A" TEXT NOT NULL, @@ -121,6 +199,37 @@ CREATE TABLE "_RoleToUser" ( CONSTRAINT "_RoleToUser_B_fkey" FOREIGN KEY ("B") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE ); +-- RedefineTables +PRAGMA defer_foreign_keys=ON; +PRAGMA foreign_keys=OFF; +CREATE TABLE "new_CaseUser" ( + "analysisId" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "userId" TEXT NOT NULL, + CONSTRAINT "CaseUser_analysisId_fkey" FOREIGN KEY ("analysisId") REFERENCES "HeatingInput" ("id") ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT "CaseUser_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); +INSERT INTO "new_CaseUser" ("userId") SELECT "userId" FROM "CaseUser"; +DROP TABLE "CaseUser"; +ALTER TABLE "new_CaseUser" RENAME TO "CaseUser"; +CREATE UNIQUE INDEX "CaseUser_analysisId_userId_key" ON "CaseUser"("analysisId", "userId"); +CREATE TABLE "new_ProcessedEnergyBill" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "analysisInputId" INTEGER NOT NULL, + "periodStartDate" DATETIME NOT NULL, + "periodEndDate" DATETIME NOT NULL, + "usageTherms" REAL NOT NULL, + "wholeHomeHeatLossRate" REAL NOT NULL, + "analysisType" INTEGER NOT NULL, + "defaultInclusion" BOOLEAN NOT NULL, + "inclusionOverride" BOOLEAN NOT NULL, + CONSTRAINT "ProcessedEnergyBill_analysisInputId_fkey" FOREIGN KEY ("analysisInputId") REFERENCES "HeatingInput" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); +INSERT INTO "new_ProcessedEnergyBill" ("analysisInputId", "analysisType", "defaultInclusion", "id", "inclusionOverride", "periodEndDate", "periodStartDate", "usageTherms", "wholeHomeHeatLossRate") SELECT "analysisInputId", "analysisType", "defaultInclusion", "id", "inclusionOverride", "periodEndDate", "periodStartDate", "usageTherms", "wholeHomeHeatLossRate" FROM "ProcessedEnergyBill"; +DROP TABLE "ProcessedEnergyBill"; +ALTER TABLE "new_ProcessedEnergyBill" RENAME TO "ProcessedEnergyBill"; +PRAGMA foreign_keys=ON; +PRAGMA defer_foreign_keys=OFF; + -- CreateIndex CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); @@ -157,6 +266,9 @@ CREATE UNIQUE INDEX "Verification_target_type_key" ON "Verification"("target", " -- CreateIndex CREATE UNIQUE INDEX "Connection_providerName_providerId_key" ON "Connection"("providerName", "providerId"); +-- CreateIndex +CREATE UNIQUE INDEX "AnalysisDataFile_analysisId_energyDataFileId_key" ON "AnalysisDataFile"("analysisId", "energyDataFileId"); + -- CreateIndex CREATE UNIQUE INDEX "_PermissionToRole_AB_unique" ON "_PermissionToRole"("A", "B"); From 934f406ea9eb823839f8090d9acfeab1463c7f68 Mon Sep 17 00:00:00 2001 From: Ethan Strominger Date: Mon, 11 Nov 2024 14:26:42 -0500 Subject: [PATCH 21/26] Modify schema.prisma to match ERD Co-authored-by: AdamFinkle --- heat-stack/prisma/README.md | 5 + .../migration.sql | 132 ++++++++++++++++++ heat-stack/prisma/schema.prisma | 77 +++++----- 3 files changed, 180 insertions(+), 34 deletions(-) create mode 100644 heat-stack/prisma/migrations/20241111192544_verified_fields/migration.sql diff --git a/heat-stack/prisma/README.md b/heat-stack/prisma/README.md index ec3bc8b4..d5744a7a 100644 --- a/heat-stack/prisma/README.md +++ b/heat-stack/prisma/README.md @@ -1,3 +1,8 @@ +# To Generate the Schema for the First Time +``` +npx prisma generate +``` + # To Change the Schema First, edit schema.prisma. diff --git a/heat-stack/prisma/migrations/20241111192544_verified_fields/migration.sql b/heat-stack/prisma/migrations/20241111192544_verified_fields/migration.sql new file mode 100644 index 00000000..d073f5b3 --- /dev/null +++ b/heat-stack/prisma/migrations/20241111192544_verified_fields/migration.sql @@ -0,0 +1,132 @@ +/* + Warnings: + + - You are about to drop the `EnergyDataFile` table. If the table is not empty, all the data it contains will be lost. + - You are about to drop the column `energyDataFileId` on the `AnalysisDataFile` table. All the data in the column will be lost. + - You are about to drop the column `contact_1_email_address` on the `HomeOwner` table. All the data in the column will be lost. + - You are about to drop the column `contact_1_name` on the `HomeOwner` table. All the data in the column will be lost. + - You are about to drop the column `contact_1_phone` on the `HomeOwner` table. All the data in the column will be lost. + - You are about to drop the column `contact_2_email_address` on the `HomeOwner` table. All the data in the column will be lost. + - You are about to drop the column `contact_2_name` on the `HomeOwner` table. All the data in the column will be lost. + - You are about to drop the column `contact_2_phone` on the `HomeOwner` table. All the data in the column will be lost. + - You are about to drop the column `name` on the `HomeOwner` table. All the data in the column will be lost. + - You are about to drop the column `contact_2_email_address` on the `Location` table. All the data in the column will be lost. + - You are about to drop the column `contact_2_phone` on the `Location` table. All the data in the column will be lost. + - You are about to drop the column `inclusionOverride` on the `ProcessedEnergyBill` table. All the data in the column will be lost. + - Added the required column `rules_engine_version` to the `Analysis` table without a default value. This is not possible if the table is not empty. + - Added the required column `energyUsageFileId` to the `AnalysisDataFile` table without a default value. This is not possible if the table is not empty. + - Added the required column `analysisId` to the `HeatingInput` table without a default value. This is not possible if the table is not empty. + - Added the required column `email1` to the `HomeOwner` table without a default value. This is not possible if the table is not empty. + - Added the required column `email2` to the `HomeOwner` table without a default value. This is not possible if the table is not empty. + - Added the required column `firstName1` to the `HomeOwner` table without a default value. This is not possible if the table is not empty. + - Added the required column `firstName2` to the `HomeOwner` table without a default value. This is not possible if the table is not empty. + - Added the required column `lastName1` to the `HomeOwner` table without a default value. This is not possible if the table is not empty. + - Added the required column `lastName2` to the `HomeOwner` table without a default value. This is not possible if the table is not empty. + - Added the required column `city` to the `Location` table without a default value. This is not possible if the table is not empty. + - Added the required column `country` to the `Location` table without a default value. This is not possible if the table is not empty. + - Added the required column `latitude` to the `Location` table without a default value. This is not possible if the table is not empty. + - Added the required column `livingAreaSquareFeet` to the `Location` table without a default value. This is not possible if the table is not empty. + - Added the required column `longitude` to the `Location` table without a default value. This is not possible if the table is not empty. + - Added the required column `state` to the `Location` table without a default value. This is not possible if the table is not empty. + - Added the required column `zipcode` to the `Location` table without a default value. This is not possible if the table is not empty. + - Added the required column `invertDefaultInclusion` to the `ProcessedEnergyBill` table without a default value. This is not possible if the table is not empty. + +*/ +-- DropTable +PRAGMA foreign_keys=off; +DROP TABLE "EnergyDataFile"; +PRAGMA foreign_keys=on; + +-- CreateTable +CREATE TABLE "EnergyUsageFile" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "provider" TEXT NOT NULL, + "fuelType" TEXT NOT NULL, + "precedingDeliveryDate" DATETIME NOT NULL, + "content" TEXT NOT NULL, + "description" TEXT NOT NULL +); + +-- RedefineTables +PRAGMA defer_foreign_keys=ON; +PRAGMA foreign_keys=OFF; +CREATE TABLE "new_Analysis" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "caseId" INTEGER NOT NULL, + "rules_engine_version" TEXT NOT NULL, + CONSTRAINT "Analysis_caseId_fkey" FOREIGN KEY ("caseId") REFERENCES "Case" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); +INSERT INTO "new_Analysis" ("caseId", "id") SELECT "caseId", "id" FROM "Analysis"; +DROP TABLE "Analysis"; +ALTER TABLE "new_Analysis" RENAME TO "Analysis"; +CREATE TABLE "new_AnalysisDataFile" ( + "analysisId" INTEGER NOT NULL, + "energyUsageFileId" INTEGER NOT NULL, + CONSTRAINT "AnalysisDataFile_analysisId_fkey" FOREIGN KEY ("analysisId") REFERENCES "Analysis" ("id") ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT "AnalysisDataFile_energyUsageFileId_fkey" FOREIGN KEY ("energyUsageFileId") REFERENCES "EnergyUsageFile" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); +INSERT INTO "new_AnalysisDataFile" ("analysisId") SELECT "analysisId" FROM "AnalysisDataFile"; +DROP TABLE "AnalysisDataFile"; +ALTER TABLE "new_AnalysisDataFile" RENAME TO "AnalysisDataFile"; +CREATE UNIQUE INDEX "AnalysisDataFile_analysisId_energyUsageFileId_key" ON "AnalysisDataFile"("analysisId", "energyUsageFileId"); +CREATE TABLE "new_HeatingInput" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "analysisId" INTEGER NOT NULL, + "fuelType" TEXT NOT NULL, + "designTemperatureOverride" BOOLEAN NOT NULL, + "heatingSystemEfficiency" INTEGER NOT NULL, + "thermostatSetPoint" INTEGER NOT NULL, + "setbackTemperature" INTEGER NOT NULL, + "setbackHoursPerDay" INTEGER NOT NULL, + "numberOfOccupants" INTEGER NOT NULL, + "estimatedWaterHeatingEfficiency" INTEGER NOT NULL, + "standByLosses" INTEGER NOT NULL, + "livingArea" REAL NOT NULL, + CONSTRAINT "HeatingInput_analysisId_fkey" FOREIGN KEY ("analysisId") REFERENCES "Analysis" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); +INSERT INTO "new_HeatingInput" ("designTemperatureOverride", "estimatedWaterHeatingEfficiency", "fuelType", "heatingSystemEfficiency", "id", "livingArea", "numberOfOccupants", "setbackHoursPerDay", "setbackTemperature", "standByLosses", "thermostatSetPoint") SELECT "designTemperatureOverride", "estimatedWaterHeatingEfficiency", "fuelType", "heatingSystemEfficiency", "id", "livingArea", "numberOfOccupants", "setbackHoursPerDay", "setbackTemperature", "standByLosses", "thermostatSetPoint" FROM "HeatingInput"; +DROP TABLE "HeatingInput"; +ALTER TABLE "new_HeatingInput" RENAME TO "HeatingInput"; +CREATE TABLE "new_HomeOwner" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "firstName1" TEXT NOT NULL, + "lastName1" TEXT NOT NULL, + "email1" TEXT NOT NULL, + "firstName2" TEXT NOT NULL, + "lastName2" TEXT NOT NULL, + "email2" TEXT NOT NULL +); +INSERT INTO "new_HomeOwner" ("id") SELECT "id" FROM "HomeOwner"; +DROP TABLE "HomeOwner"; +ALTER TABLE "new_HomeOwner" RENAME TO "HomeOwner"; +CREATE TABLE "new_Location" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "address" TEXT NOT NULL, + "city" TEXT NOT NULL, + "state" TEXT NOT NULL, + "zipcode" TEXT NOT NULL, + "country" TEXT NOT NULL, + "livingAreaSquareFeet" INTEGER NOT NULL, + "latitude" REAL NOT NULL, + "longitude" REAL NOT NULL +); +INSERT INTO "new_Location" ("address", "id") SELECT "address", "id" FROM "Location"; +DROP TABLE "Location"; +ALTER TABLE "new_Location" RENAME TO "Location"; +CREATE TABLE "new_ProcessedEnergyBill" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "analysisInputId" INTEGER NOT NULL, + "periodStartDate" DATETIME NOT NULL, + "periodEndDate" DATETIME NOT NULL, + "usageTherms" REAL NOT NULL, + "wholeHomeHeatLossRate" REAL NOT NULL, + "analysisType" INTEGER NOT NULL, + "defaultInclusion" BOOLEAN NOT NULL, + "invertDefaultInclusion" BOOLEAN NOT NULL, + CONSTRAINT "ProcessedEnergyBill_analysisInputId_fkey" FOREIGN KEY ("analysisInputId") REFERENCES "HeatingInput" ("id") ON DELETE CASCADE ON UPDATE CASCADE +); +INSERT INTO "new_ProcessedEnergyBill" ("analysisInputId", "analysisType", "defaultInclusion", "id", "periodEndDate", "periodStartDate", "usageTherms", "wholeHomeHeatLossRate") SELECT "analysisInputId", "analysisType", "defaultInclusion", "id", "periodEndDate", "periodStartDate", "usageTherms", "wholeHomeHeatLossRate" FROM "ProcessedEnergyBill"; +DROP TABLE "ProcessedEnergyBill"; +ALTER TABLE "new_ProcessedEnergyBill" RENAME TO "ProcessedEnergyBill"; +PRAGMA foreign_keys=ON; +PRAGMA defer_foreign_keys=OFF; diff --git a/heat-stack/prisma/schema.prisma b/heat-stack/prisma/schema.prisma index 43edf827..352b8c92 100644 --- a/heat-stack/prisma/schema.prisma +++ b/heat-stack/prisma/schema.prisma @@ -173,15 +173,19 @@ model Connection { // HEAT schema starts here model Analysis { - id Int @id @default(autoincrement()) - case Case @relation(fields: [caseId], references: [id], onDelete: Cascade, onUpdate: Cascade) - caseId Int - heatingOutput HeatingOutput[] - analysisDataFile AnalysisDataFile[] + id Int @id @default(autoincrement()) + case Case @relation(fields: [caseId], references: [id], onDelete: Cascade, onUpdate: Cascade) + caseId Int + heatingInput HeatingInput[] + analysisDataFile AnalysisDataFile[] + heatingOutput HeatingOutput[] + rules_engine_version String } model HeatingInput { id Int @id @default(autoincrement()) + analysis Analysis @relation(fields: [analysisId], references: [id], onDelete: Cascade, onUpdate: Cascade) + analysisId Int caseUser CaseUser[] fuelType String designTemperatureOverride Boolean @@ -197,16 +201,16 @@ model HeatingInput { } model ProcessedEnergyBill { - id Int @id @default(autoincrement()) - AnalysisInput HeatingInput @relation(fields: [analysisInputId], references: [id], onDelete: Cascade, onUpdate: Cascade) - analysisInputId Int - periodStartDate DateTime - periodEndDate DateTime - usageTherms Float - wholeHomeHeatLossRate Float - analysisType Int - defaultInclusion Boolean - inclusionOverride Boolean + id Int @id @default(autoincrement()) + AnalysisInput HeatingInput @relation(fields: [analysisInputId], references: [id], onDelete: Cascade, onUpdate: Cascade) + analysisInputId Int + periodStartDate DateTime + periodEndDate DateTime + usageTherms Float + wholeHomeHeatLossRate Float + analysisType Int + defaultInclusion Boolean + invertDefaultInclusion Boolean } model HeatingOutput { @@ -224,12 +228,12 @@ model HeatingOutput { maximumHeatLoad Float } -model EnergyDataFile { +model EnergyUsageFile { id Int @id @default(autoincrement()) provider String fuelType String precedingDeliveryDate DateTime - filePath String + content String description String analysisDataFile AnalysisDataFile[] } @@ -237,9 +241,9 @@ model EnergyDataFile { model AnalysisDataFile { analysis Analysis @relation(fields: [analysisId], references: [id], onDelete: Cascade, onUpdate: Cascade) analysisId Int - EnergyDataFile EnergyDataFile @relation(fields: [energyDataFileId], references: [id], onDelete: Cascade, onUpdate: Cascade) - energyDataFileId Int - @@unique([analysisId, energyDataFileId]) + EnergyUsageFile EnergyUsageFile @relation(fields: [energyUsageFileId], references: [id], onDelete: Cascade, onUpdate: Cascade) + energyUsageFileId Int + @@unique([analysisId, energyUsageFileId]) } model Case { @@ -252,22 +256,27 @@ model Case { } model HomeOwner { - id Int @id @default(autoincrement()) - case Case[] - name String - contact_1_name String - contact_1_email_address String - contact_1_phone String - contact_2_name String - contact_2_email_address String - contact_2_phone String + id Int @id @default(autoincrement()) + case Case[] + firstName1 String + lastName1 String + email1 String + firstName2 String + lastName2 String + email2 String } + model Location { - id Int @id @default(autoincrement()) - case Case[] - contact_2_email_address String - contact_2_phone String - address String + id Int @id @default(autoincrement()) + case Case[] + address String + city String + state String + zipcode String + country String + livingAreaSquareFeet Int + latitude Float + longitude Float } model CaseUser { From d9e187a78254b7d7599d9353f0473d143a796a06 Mon Sep 17 00:00:00 2001 From: Ethan Strominger Date: Mon, 9 Dec 2024 10:27:13 -0500 Subject: [PATCH 22/26] Formatting --- design_temp/validate_counties.py | 53 ++++++++++++------- python/src/rules_engine/parser.py | 11 ++-- python/tests/test_rules_engine/test_parser.py | 4 +- 3 files changed, 40 insertions(+), 28 deletions(-) diff --git a/design_temp/validate_counties.py b/design_temp/validate_counties.py index 71fa4985..e80cd7a5 100644 --- a/design_temp/validate_counties.py +++ b/design_temp/validate_counties.py @@ -8,15 +8,19 @@ CENSUS_DOCS_BASE_URL = "https://www2.census.gov/geo/docs/reference" CENSUS_STATE_PATH = "/state.txt" CENSUS_COUNTY_PATH = "/codes2020/national_county2020.txt" -CENSUS_DELIMETER = '|' -NEW_LINE = '\n' -NEW_HEADERS="state_id,state_name,state_abbr,county_fp,county_ns,county_name,county_design_temp" +CENSUS_DELIMETER = "|" +NEW_LINE = "\n" +NEW_HEADERS = ( + "state_id,state_name,state_abbr,county_fp,county_ns,county_name,county_design_temp" +) + class State(BaseModel): state_id: str state_abbr: str state_name: str + class County(BaseModel): state_id: str state_abbr: str @@ -25,65 +29,76 @@ class County(BaseModel): county_ns: str county_name: str + class DTBC(BaseModel): state: str county: str temp: int + _counties = {} -_states={} -_dtbc={} +_states = {} +_dtbc = {} + + def load_design_temp_data(): - with open(DESIGN_TEMP_DIR / "design_temp_by_county.csv") as f: reader = csv.DictReader(f) for row in reader: item = DTBC( - state=row["state"], county=row["county"],temp=row["design_temp"] + state=row["state"], county=row["county"], temp=row["design_temp"] ) if row["state"] in _dtbc: - _dtbc[row["state"]].append(item) + _dtbc[row["state"]].append(item) else: _dtbc[row["state"]] = [item] - + def fetch_census_counties(): census_url = CENSUS_DOCS_BASE_URL + CENSUS_COUNTY_PATH response = requests.get(census_url) - reader = csv.DictReader(f=io.StringIO(response.text),delimiter=CENSUS_DELIMETER) + reader = csv.DictReader(f=io.StringIO(response.text), delimiter=CENSUS_DELIMETER) for row in reader: sid = row["STATEFP"] sn = _states[sid].state_name item = County( - state_id=sid, state_abbr=_states[sid].state_abbr, state_name=sn,county_fp=row["COUNTYFP"], county_ns=row["COUNTYNS"],county_name=row["COUNTYNAME"] + state_id=sid, + state_abbr=_states[sid].state_abbr, + state_name=sn, + county_fp=row["COUNTYFP"], + county_ns=row["COUNTYNS"], + county_name=row["COUNTYNAME"], ) _counties[sn].append(item) - + + def fetch_census_states(): states_url = CENSUS_DOCS_BASE_URL + CENSUS_STATE_PATH response = requests.get(states_url) - reader = csv.DictReader(f=io.StringIO(response.text),delimiter=CENSUS_DELIMETER) + reader = csv.DictReader(f=io.StringIO(response.text), delimiter=CENSUS_DELIMETER) for row in reader: _counties[row["STATE_NAME"]] = [] item = State( - state_id=row["STATE"], state_abbr=row["STUSAB"], state_name=row["STATE_NAME"] + state_id=row["STATE"], + state_abbr=row["STUSAB"], + state_name=row["STATE_NAME"], ) _states[row["STATE"]] = item - if __name__ == "__main__": - fetch_census_states() fetch_census_counties() load_design_temp_data() - with open(DESIGN_TEMP_DIR / "merged_structure_temps.csv", "w", newline=NEW_LINE) as oFile: + with open( + DESIGN_TEMP_DIR / "merged_structure_temps.csv", "w", newline=NEW_LINE + ) as oFile: oFile.write(NEW_HEADERS) for s, cbs in _counties.items(): d_row = _dtbc.get(s) @@ -91,5 +106,5 @@ def fetch_census_states(): for d in d_row: for c in cbs: if d.county in c.county_name: - ostr=f"\n{c.state_id},{s},{c.state_abbr},{c.county_fp},{c.county_ns},{d.county},{d.temp}" - oFile.write(ostr) \ No newline at end of file + ostr = f"\n{c.state_id},{s},{c.state_abbr},{c.county_fp},{c.county_ns},{d.county},{d.temp}" + oFile.write(ostr) diff --git a/python/src/rules_engine/parser.py b/python/src/rules_engine/parser.py index 7afe0ced..ae461a88 100644 --- a/python/src/rules_engine/parser.py +++ b/python/src/rules_engine/parser.py @@ -95,17 +95,16 @@ def parse_gas_bill_xml(data_file: str) -> NaturalGasBillingInput: for interval_reading in meter_reading.interval_readings: records.append( NaturalGasBillingRecordInput( - period_start = interval_reading.time_period.start, # datetime.utcfromtimestamp(interval_reading.time_period.start).date(), - period_end = interval_reading.time_period.start + interval_reading.time_period.duration, # datetime.utcfromtimestamp(interval_reading.time_period.start + interval_reading.time_period.duration).date(), - usage_therms = interval_reading.value, - inclusion_override = None + period_start=interval_reading.time_period.start, # datetime.utcfromtimestamp(interval_reading.time_period.start).date(), + period_end=interval_reading.time_period.start + + interval_reading.time_period.duration, # datetime.utcfromtimestamp(interval_reading.time_period.start + interval_reading.time_period.duration).date(), + usage_therms=interval_reading.value, + inclusion_override=None, ) ) return NaturalGasBillingInput(records=records) - - def parse_gas_bill( data: str, company: NaturalGasCompany | None = None ) -> NaturalGasBillingInput: diff --git a/python/tests/test_rules_engine/test_parser.py b/python/tests/test_rules_engine/test_parser.py index 598e72cf..9e29d969 100644 --- a/python/tests/test_rules_engine/test_parser.py +++ b/python/tests/test_rules_engine/test_parser.py @@ -111,9 +111,7 @@ def test_parse_gas_bill_national_grid(): def test_parse_xml_natural_gas(): - _validate_xml_natural_gas( - parser.parse_gas_bill_xml(_read_gas_bill_xml()) - ) + _validate_xml_natural_gas(parser.parse_gas_bill_xml(_read_gas_bill_xml())) def test_detect_natural_gas_company(): From d536a45cb9039202155ec454a0a6716360b6a0b2 Mon Sep 17 00:00:00 2001 From: Ethan Strominger Date: Mon, 9 Dec 2024 10:28:50 -0500 Subject: [PATCH 23/26] Formatting --- python/src/rules_engine/parser.py | 3 ++- python/tests/test_rules_engine/test_utils.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/python/src/rules_engine/parser.py b/python/src/rules_engine/parser.py index ae461a88..18fab992 100644 --- a/python/src/rules_engine/parser.py +++ b/python/src/rules_engine/parser.py @@ -9,9 +9,10 @@ from datetime import datetime, timedelta from enum import StrEnum -from .pydantic_models import NaturalGasBillingInput, NaturalGasBillingRecordInput from greenbutton_objects import parse +from .pydantic_models import NaturalGasBillingInput, NaturalGasBillingRecordInput + class NaturalGasCompany(StrEnum): EVERSOURCE = "eversource" diff --git a/python/tests/test_rules_engine/test_utils.py b/python/tests/test_rules_engine/test_utils.py index 1ce50aa5..32a6c81b 100644 --- a/python/tests/test_rules_engine/test_utils.py +++ b/python/tests/test_rules_engine/test_utils.py @@ -1,5 +1,5 @@ import csv -from datetime import datetime, timedelta, date +from datetime import date, datetime, timedelta from pathlib import Path from typing import Any, Sequence From 905e8b68b2ed5f67d2969d659027fd0e8cf0225d Mon Sep 17 00:00:00 2001 From: Ethan Strominger Date: Mon, 9 Dec 2024 22:52:02 -0500 Subject: [PATCH 24/26] Fix incorrect change to var name --- python/src/rules_engine/parser.py | 4 ++-- python/src/rules_engine/pydantic_models.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/python/src/rules_engine/parser.py b/python/src/rules_engine/parser.py index 18fab992..d68bcc98 100644 --- a/python/src/rules_engine/parser.py +++ b/python/src/rules_engine/parser.py @@ -96,8 +96,8 @@ def parse_gas_bill_xml(data_file: str) -> NaturalGasBillingInput: for interval_reading in meter_reading.interval_readings: records.append( NaturalGasBillingRecordInput( - period_start=interval_reading.time_period.start, # datetime.utcfromtimestamp(interval_reading.time_period.start).date(), - period_end=interval_reading.time_period.start + period_start_date=interval_reading.time_period.start, # datetime.utcfromtimestamp(interval_reading.time_period.start).date(), + period_end_date=interval_reading.time_period.start + interval_reading.time_period.duration, # datetime.utcfromtimestamp(interval_reading.time_period.start + interval_reading.time_period.duration).date(), usage_therms=interval_reading.value, inclusion_override=None, diff --git a/python/src/rules_engine/pydantic_models.py b/python/src/rules_engine/pydantic_models.py index 85842d44..6977cff0 100644 --- a/python/src/rules_engine/pydantic_models.py +++ b/python/src/rules_engine/pydantic_models.py @@ -97,8 +97,8 @@ class OilPropaneBillingInput(BaseModel): class NaturalGasBillingRecordInput(BaseModel): """From Natural Gas tab. A single row of the Billing input table.""" - period_start: datetime = Field(description="Natural Gas!A") - period_end: datetime = Field(description="Natural Gas!B") + period_start_date: datetime = Field(description="Natural Gas!A") + period_end_date: datetime = Field(description="Natural Gas!B") usage_therms: float = Field(description="Natural Gas!D") inclusion_override: Optional[bool] = Field(description="Natural Gas!E") From 6284ee565711702e8c10680a225ce5dd03666d4f Mon Sep 17 00:00:00 2001 From: Ethan Strominger Date: Tue, 10 Dec 2024 04:50:35 -0500 Subject: [PATCH 25/26] Restore missing file --- .../cases/parsing/xml/abridged/gas_direct.xml | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 python/tests/test_rules_engine/cases/parsing/xml/abridged/gas_direct.xml diff --git a/python/tests/test_rules_engine/cases/parsing/xml/abridged/gas_direct.xml b/python/tests/test_rules_engine/cases/parsing/xml/abridged/gas_direct.xml new file mode 100644 index 00000000..d744a0a6 --- /dev/null +++ b/python/tests/test_rules_engine/cases/parsing/xml/abridged/gas_direct.xml @@ -0,0 +1,107 @@ + + + urn:uuid:5762c9e8-4e65-3b0c-83b3-7874683f3dbe + + + Opower ESPI Third Party Batch Feed v1 + 2024-06-21 + + urn:uuid:db678d4d-d9fe-3c0c-96f9-c13142c295e1 + + + + + 1 MAIN ST, ANYTOWN ME 12345 + 2024-06-21 + 2011-11-30T12:00:00.000Z + + + + 1 + + + + + + urn:uuid:cb36cc47-2cfb-3e47-abb9-7866f42cc194 + + + + + + + 2024-06-21 + 2011-11-30T12:00:00.000Z + + + + + + + urn:uuid:e7c7cd10-5e47-3d9c-8684-bd9e7eb401d3 + + + 2024-06-21 + 2011-11-30T12:00:00.000Z + + + 840 + -3 + 169 + + + + + urn:uuid:1efd2ba9-8c1a-3937-b7c0-ae55733e9e5e + + + + + + 92102400 + 1622005200 + + + 5100000 + + 3024000 + 1621987200 + + 37000 + + + 2493000 + + 2419200 + 1625011200 + + 14000 + + + 3281000 + + 2592000 + 1627430400 + + 21000 + + + 4207000 + + 2851200 + 1630022400 + + 27000 + + + 5543000 + + 2332800 + 1632873600 + + 41000 + + + + + From 486c0e0b33234578e0f84fb889fff40df5a2c878 Mon Sep 17 00:00:00 2001 From: Ethan Strominger Date: Tue, 10 Dec 2024 05:52:26 -0500 Subject: [PATCH 26/26] Reconcile with main --- heat-stack/Dockerfile | 98 ------- heat-stack/Dockerfile.dockerignore | 9 - python/requirements.txt | 1 - python/src/rules_engine/parser.py | 19 -- python/src/rules_engine/pydantic_models.py | 2 +- .../cases/parsing/xml/abridged/gas_direct.xml | 107 -------- python/tests/test_rules_engine/test_engine.py | 2 +- python/tests/test_rules_engine/test_parser.py | 27 -- .../merlin/Eversource_Green_Button.csv | 16 -- .../merlin/Eversource_Green_Button.xml | 253 ------------------ .../cases/parsing/xml/abridged/gas_direct.xml | 107 -------- 11 files changed, 2 insertions(+), 639 deletions(-) delete mode 100644 heat-stack/Dockerfile delete mode 100644 heat-stack/Dockerfile.dockerignore delete mode 100644 python/tests/test_rules_engine/cases/parsing/xml/abridged/gas_direct.xml delete mode 100644 rules-engine/tests/test_rules_engine/cases/examples/natural_gas/merlin/Eversource_Green_Button.csv delete mode 100644 rules-engine/tests/test_rules_engine/cases/examples/natural_gas/merlin/Eversource_Green_Button.xml delete mode 100644 rules-engine/tests/test_rules_engine/cases/parsing/xml/abridged/gas_direct.xml diff --git a/heat-stack/Dockerfile b/heat-stack/Dockerfile deleted file mode 100644 index 3cd618a6..00000000 --- a/heat-stack/Dockerfile +++ /dev/null @@ -1,98 +0,0 @@ -# This file is moved to the root directory before building the image - -# base node image -FROM node:20-bookworm-slim as base - -# set for base and all layer that inherit from it -ENV NODE_ENV production - -# Install openssl for Prisma -RUN apt-get update && apt-get install -y fuse3 openssl sqlite3 ca-certificates - -# Install all node_modules, including dev dependencies -FROM base as deps - -WORKDIR /myapp - -ADD package.json package-lock.json .npmrc ./ -RUN npm install --include=dev - -# Setup production node_modules -FROM base as production-deps - -WORKDIR /myapp - -COPY --from=deps /myapp/node_modules /myapp/node_modules -ADD package.json package-lock.json .npmrc ./ -RUN npm prune --omit=dev - -# Build the app -FROM base as build - -ARG COMMIT_SHA -ENV COMMIT_SHA=$COMMIT_SHA - -# Use the following environment variables to configure Sentry -# ENV SENTRY_ORG= -# ENV SENTRY_PROJECT= - - -WORKDIR /myapp - -COPY --from=deps /myapp/node_modules /myapp/node_modules - -ADD prisma . -RUN npx prisma generate - -ADD . . - -# Mount the secret and set it as an environment variable and run the build -RUN --mount=type=secret,id=SENTRY_AUTH_TOKEN \ - export SENTRY_AUTH_TOKEN=$(cat /run/secrets/SENTRY_AUTH_TOKEN) && \ - npm run build - -# Finally, build the production image with minimal footprint -FROM base - -ENV FLY="true" -ENV LITEFS_DIR="/litefs/data" -ENV DATABASE_FILENAME="sqlite.db" -ENV DATABASE_PATH="$LITEFS_DIR/$DATABASE_FILENAME" -ENV DATABASE_URL="file:$DATABASE_PATH" -ENV CACHE_DATABASE_FILENAME="cache.db" -ENV CACHE_DATABASE_PATH="$LITEFS_DIR/$CACHE_DATABASE_FILENAME" -ENV INTERNAL_PORT="8080" -ENV PORT="8081" -ENV NODE_ENV="production" -# For WAL support: https://github.com/prisma/prisma-engines/issues/4675#issuecomment-1914383246 -ENV PRISMA_SCHEMA_DISABLE_ADVISORY_LOCK = "1" - -# add shortcut for connecting to database CLI -RUN echo "#!/bin/sh\nset -x\nsqlite3 \$DATABASE_URL" > /usr/local/bin/database-cli && chmod +x /usr/local/bin/database-cli - -WORKDIR /myapp - -# Generate random value and save it to .env file which will be loaded by dotenv -RUN INTERNAL_COMMAND_TOKEN=$(openssl rand -hex 32) && \ - echo "INTERNAL_COMMAND_TOKEN=$INTERNAL_COMMAND_TOKEN" > .env - -COPY --from=production-deps /myapp/node_modules /myapp/node_modules -COPY --from=build /myapp/node_modules/.prisma /myapp/node_modules/.prisma - -COPY --from=build /myapp/server-build /myapp/server-build -COPY --from=build /myapp/build /myapp/build - -# HEAT Stack custom line for Pyodide -COPY --from=build /myapp/public /myapp/public -COPY --from=build /myapp/package.json /myapp/package.json -COPY --from=build /myapp/prisma /myapp/prisma -COPY --from=build /myapp/app/components/ui/icons /myapp/app/components/ui/icons - -# prepare for litefs -COPY --from=flyio/litefs:0.5.11 /usr/local/bin/litefs /usr/local/bin/litefs -ADD other/litefs.yml /etc/litefs.yml -RUN mkdir -p /data ${LITEFS_DIR} - -ADD . . - -CMD ["litefs", "mount"] diff --git a/heat-stack/Dockerfile.dockerignore b/heat-stack/Dockerfile.dockerignore deleted file mode 100644 index 6e187657..00000000 --- a/heat-stack/Dockerfile.dockerignore +++ /dev/null @@ -1,9 +0,0 @@ -# This file is moved to the root directory before building the image - -/node_modules -*.log -.DS_Store -.env -/.cache -/public/build -/build diff --git a/python/requirements.txt b/python/requirements.txt index 8fa60f51..2afeaaa2 100644 --- a/python/requirements.txt +++ b/python/requirements.txt @@ -14,4 +14,3 @@ typing-extensions==4.8.0 # via # pydantic # pydantic-core -greenbutton_objects @ git+https://github.com/codeforboston/greenbutton_objects@main diff --git a/python/src/rules_engine/parser.py b/python/src/rules_engine/parser.py index d68bcc98..006b8a27 100644 --- a/python/src/rules_engine/parser.py +++ b/python/src/rules_engine/parser.py @@ -9,8 +9,6 @@ from datetime import datetime, timedelta from enum import StrEnum -from greenbutton_objects import parse - from .pydantic_models import NaturalGasBillingInput, NaturalGasBillingRecordInput @@ -89,23 +87,6 @@ def _detect_gas_company(data: str) -> NaturalGasCompany: ) -def parse_gas_bill_xml(data_file: str) -> NaturalGasBillingInput: - bill = parse.parse_feed(str(data_file)) - records = [] - for meter_reading in bill.usage_points[0].meter_readings: - for interval_reading in meter_reading.interval_readings: - records.append( - NaturalGasBillingRecordInput( - period_start_date=interval_reading.time_period.start, # datetime.utcfromtimestamp(interval_reading.time_period.start).date(), - period_end_date=interval_reading.time_period.start - + interval_reading.time_period.duration, # datetime.utcfromtimestamp(interval_reading.time_period.start + interval_reading.time_period.duration).date(), - usage_therms=interval_reading.value, - inclusion_override=None, - ) - ) - return NaturalGasBillingInput(records=records) - - def parse_gas_bill( data: str, company: NaturalGasCompany | None = None ) -> NaturalGasBillingInput: diff --git a/python/src/rules_engine/pydantic_models.py b/python/src/rules_engine/pydantic_models.py index 6977cff0..fce42087 100644 --- a/python/src/rules_engine/pydantic_models.py +++ b/python/src/rules_engine/pydantic_models.py @@ -3,7 +3,7 @@ """ from dataclasses import dataclass -from datetime import datetime +from datetime import date, datetime from enum import Enum from functools import cached_property from typing import Annotated, Any, Literal, Optional, Sequence diff --git a/python/tests/test_rules_engine/cases/parsing/xml/abridged/gas_direct.xml b/python/tests/test_rules_engine/cases/parsing/xml/abridged/gas_direct.xml deleted file mode 100644 index d744a0a6..00000000 --- a/python/tests/test_rules_engine/cases/parsing/xml/abridged/gas_direct.xml +++ /dev/null @@ -1,107 +0,0 @@ - - - urn:uuid:5762c9e8-4e65-3b0c-83b3-7874683f3dbe - - - Opower ESPI Third Party Batch Feed v1 - 2024-06-21 - - urn:uuid:db678d4d-d9fe-3c0c-96f9-c13142c295e1 - - - - - 1 MAIN ST, ANYTOWN ME 12345 - 2024-06-21 - 2011-11-30T12:00:00.000Z - - - - 1 - - - - - - urn:uuid:cb36cc47-2cfb-3e47-abb9-7866f42cc194 - - - - - - - 2024-06-21 - 2011-11-30T12:00:00.000Z - - - - - - - urn:uuid:e7c7cd10-5e47-3d9c-8684-bd9e7eb401d3 - - - 2024-06-21 - 2011-11-30T12:00:00.000Z - - - 840 - -3 - 169 - - - - - urn:uuid:1efd2ba9-8c1a-3937-b7c0-ae55733e9e5e - - - - - - 92102400 - 1622005200 - - - 5100000 - - 3024000 - 1621987200 - - 37000 - - - 2493000 - - 2419200 - 1625011200 - - 14000 - - - 3281000 - - 2592000 - 1627430400 - - 21000 - - - 4207000 - - 2851200 - 1630022400 - - 27000 - - - 5543000 - - 2332800 - 1632873600 - - 41000 - - - - - diff --git a/python/tests/test_rules_engine/test_engine.py b/python/tests/test_rules_engine/test_engine.py index 7f9a70de..ca63f742 100644 --- a/python/tests/test_rules_engine/test_engine.py +++ b/python/tests/test_rules_engine/test_engine.py @@ -1,4 +1,4 @@ -from datetime import datetime +from datetime import date, datetime from typing import Any import pytest diff --git a/python/tests/test_rules_engine/test_parser.py b/python/tests/test_rules_engine/test_parser.py index 9e29d969..6b9ee2df 100644 --- a/python/tests/test_rules_engine/test_parser.py +++ b/python/tests/test_rules_engine/test_parser.py @@ -23,12 +23,6 @@ def _read_gas_bill_national_grid() -> str: return f.read() -def _read_gas_bill_xml() -> str: - """Read a test natural gas bill from a test National Grid CSV""" - # TODO: Pass the file as a string rather than passing the file name - return ROOT_DIR.parent / "parsing" / "xml" / "abridged" / "gas_direct.xml" - - def _validate_eversource(result): """Validate the result of reading an Eversource CSV.""" assert len(result.records) == 36 @@ -63,23 +57,6 @@ def _validate_national_grid(result): assert second_row.inclusion_override == None -def _validate_xml_natural_gas(result): - """Validate the result of reading a National Grid CSV.""" - assert len(result.records) == 5 - for row in result.records: - assert isinstance(row, NaturalGasBillingRecordInput) - - # input: Natural gas billing,11/5/2020,12/3/2020,36,therms,$65.60 , - # from excel: 11/6/2020,12/3/2020,28,36,,1,1.29,0.99 - - second_row = result.records[1] - assert second_row.period_start_date == date(2021, 6, 30) - assert second_row.period_end_date == date(2021, 7, 28) - assert isinstance(second_row.usage_therms, float) - assert second_row.usage_therms == 14 - assert second_row.inclusion_override == None - - def test_parse_gas_bill(): """ Tests the logic of parse_gas_bill. @@ -110,10 +87,6 @@ def test_parse_gas_bill_national_grid(): ) -def test_parse_xml_natural_gas(): - _validate_xml_natural_gas(parser.parse_gas_bill_xml(_read_gas_bill_xml())) - - def test_detect_natural_gas_company(): """Tests if the natural gas company is correctly detected from the parsed csv.""" read_eversource = _read_gas_bill_eversource() diff --git a/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/merlin/Eversource_Green_Button.csv b/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/merlin/Eversource_Green_Button.csv deleted file mode 100644 index 7f43f5cf..00000000 --- a/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/merlin/Eversource_Green_Button.csv +++ /dev/null @@ -1,16 +0,0 @@ -1 MAIN STREET BOSTON MA US 01234-5678 ,,,,,, -Data from 8/31/2023 to 7/1/2024,,,,,, -Requested By bob on 7/27/2024,,,,,, -Meter No: ,22945690,,,,, -,,,,,, -Account,Read Date,Usage,Number of Days,Usage per day,Charge,Average Temperature -73218880816,7/1/2024,-56,31,-1.81,$10.00 ,73 -73218880816,5/31/2024,-244,31,-7.87,$10.00 ,61 -73218880816,3/29/2024,254,30,8.47,$92.88 ,0 -73218880816,2/28/2024,571,29,19.69,$196.32 ,0 -73218880816,1/30/2024,1030,32,32.19,$344.85 ,0 -73218880816,12/29/2023,838,30,27.93,$229.18 ,0 -73218880816,11/29/2023,702,29,24.21,$193.59 ,0 -73218880816,10/31/2023,450,28,16.07,$127.70 ,0 -73218880816,10/3/2023,233,33,7.06,$70.94 ,0 -73218880816,8/31/2023,57,30,1.9,$24.91 ,0 diff --git a/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/merlin/Eversource_Green_Button.xml b/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/merlin/Eversource_Green_Button.xml deleted file mode 100644 index 7510b199..00000000 --- a/rules-engine/tests/test_rules_engine/cases/examples/natural_gas/merlin/Eversource_Green_Button.xml +++ /dev/null @@ -1,253 +0,0 @@ - - urn:uuid:046638c0-8701-2342-9d80-0800200c8a23 - - ThirdPartyX Batch Feed - 2024-07-27T06:53:27 - - - - - - - 1 - - - urn:uuid:046638c0-8701-2342-9d80-0800200c8a23 - - - - - - 2024-07-27T06:53:27 - 1 Main Street Boston MA US 01234-5678, - 2024-07-27T06:53:27 - - - - - - urn:uuid:046638c0-8701-2342-9d80-0800200c8a23 - - - - - 2024-07-27T06:53:27 - 2024-07-27T06:53:27 - - - - - - 2592000 - 1722092007.25295 - - - 2491000 - - 0 - - - 2592000 - 1722092007.25295 - - 57000 - - - - - 2851200 - 1722092007.25295 - - - 7094000 - - 0 - - - 2851200 - 1722092007.25295 - - 233000 - - - - - 2419200 - 1722092007.25295 - - - 12770000 - - 0 - - - 2419200 - 1722092007.25295 - - 450000 - - - - - 2505600 - 1722092007.25295 - - - 19359000 - - 0 - - - 2505600 - 1722092007.25295 - - 702000 - - - - - 2592000 - 1722092007.25295 - - - 22918000 - - 0 - - - 2592000 - 1722092007.25295 - - 838000 - - - - - 2764800 - 1722092007.25295 - - - 34485000 - - 0 - - - 2764800 - 1722092007.25295 - - 1030000 - - - - - 2505600 - 1722092007.25295 - - - 19632000 - - 0 - - - 2505600 - 1722092007.25295 - - 571000 - - - - - 2592000 - 1722092007.25295 - - - 9288000 - - 0 - - - 2592000 - 1722092007.25295 - - 254000 - - - - - 2678400 - 1722092007.25295 - - - 1000000 - - 0 - - - 2678400 - 1722092007.25295 - - -244000 - - - - - 2678400 - 1722092007.25295 - - - 1000000 - - 0 - - - 2678400 - 1722092007.25295 - - -56000 - - - - urn:uuid:046638c0-8701-2342-9d80-0800200c8a23 - - - 2024-07-27T06:53:27 - - 2024-07-27T06:53:27 - - - - - - urn:uuid:046638c0-8701-2342-9d80-0800200c8a23 - - - 2024-07-27T06:53:27 - 2024-07-27T06:53:27 - - - - urn:uuid:046638c0-8701-2342-9d80-0800200c8a23 - - - 2024-07-27T06:53:27 - Usage Summary - 2024-07-27T06:53:27 - - - - - B40E2000 - 3600 - 360E2000 - 18000 - - - urn:uuid:046638c0-8701-2342-9d80-0800200c8a23 - - - 2024-07-27T06:53:27 - DST For North America - 2024-07-27T06:53:27 - - \ No newline at end of file diff --git a/rules-engine/tests/test_rules_engine/cases/parsing/xml/abridged/gas_direct.xml b/rules-engine/tests/test_rules_engine/cases/parsing/xml/abridged/gas_direct.xml deleted file mode 100644 index d744a0a6..00000000 --- a/rules-engine/tests/test_rules_engine/cases/parsing/xml/abridged/gas_direct.xml +++ /dev/null @@ -1,107 +0,0 @@ - - - urn:uuid:5762c9e8-4e65-3b0c-83b3-7874683f3dbe - - - Opower ESPI Third Party Batch Feed v1 - 2024-06-21 - - urn:uuid:db678d4d-d9fe-3c0c-96f9-c13142c295e1 - - - - - 1 MAIN ST, ANYTOWN ME 12345 - 2024-06-21 - 2011-11-30T12:00:00.000Z - - - - 1 - - - - - - urn:uuid:cb36cc47-2cfb-3e47-abb9-7866f42cc194 - - - - - - - 2024-06-21 - 2011-11-30T12:00:00.000Z - - - - - - - urn:uuid:e7c7cd10-5e47-3d9c-8684-bd9e7eb401d3 - - - 2024-06-21 - 2011-11-30T12:00:00.000Z - - - 840 - -3 - 169 - - - - - urn:uuid:1efd2ba9-8c1a-3937-b7c0-ae55733e9e5e - - - - - - 92102400 - 1622005200 - - - 5100000 - - 3024000 - 1621987200 - - 37000 - - - 2493000 - - 2419200 - 1625011200 - - 14000 - - - 3281000 - - 2592000 - 1627430400 - - 21000 - - - 4207000 - - 2851200 - 1630022400 - - 27000 - - - 5543000 - - 2332800 - 1632873600 - - 41000 - - - - -