mirror of
https://github.com/Hestia-Homes/assessment-model.git
synced 2026-06-08 11:37:25 +00:00
Merge pull request #148 from Hestia-Homes/new-reporting
Added recommendations index
This commit is contained in:
commit
fb342d0955
4 changed files with 4852 additions and 28 deletions
1
src/app/db/migrations/0136_boring_charles_xavier.sql
Normal file
1
src/app/db/migrations/0136_boring_charles_xavier.sql
Normal file
|
|
@ -0,0 +1 @@
|
|||
CREATE INDEX "recommendation_property_id_idx" ON "recommendation" USING btree ("property_id");
|
||||
4811
src/app/db/migrations/meta/0136_snapshot.json
Normal file
4811
src/app/db/migrations/meta/0136_snapshot.json
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -953,6 +953,13 @@
|
|||
"when": 1765214013546,
|
||||
"tag": "0135_lovely_spectrum",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 136,
|
||||
"version": "7",
|
||||
"when": 1765397663012,
|
||||
"tag": "0136_boring_charles_xavier",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -10,39 +10,44 @@ import {
|
|||
bigint,
|
||||
pgEnum,
|
||||
integer,
|
||||
index,
|
||||
} from "drizzle-orm/pg-core";
|
||||
import { Material, material } from "./materials";
|
||||
import { InferModel } from "drizzle-orm";
|
||||
import { z } from "zod";
|
||||
|
||||
export const recommendation = pgTable("recommendation", {
|
||||
id: bigserial("id", { mode: "bigint" }).primaryKey(),
|
||||
propertyId: bigint("property_id", { mode: "bigint" })
|
||||
.notNull()
|
||||
.references(() => property.id),
|
||||
createdAt: timestamp("created_at").notNull().defaultNow(),
|
||||
type: text("type").notNull(),
|
||||
measureType: text("measure_type"),
|
||||
description: text("description").notNull(),
|
||||
estimatedCost: real("estimated_cost"),
|
||||
constingencyCost: real("contingency_cost"),
|
||||
// default will indicate whether a mtaterial is currently being used in a recommendation and we will use this boolean to switch
|
||||
// between materials in the UI and switch off all materials entirely
|
||||
default: boolean("default").notNull(),
|
||||
startingUValue: real("starting_u_value"),
|
||||
newUValue: real("new_u_value"),
|
||||
sapPoints: real("sap_points"),
|
||||
heatDemand: real("heat_demand"),
|
||||
kwhSavings: real("kwh_savings"),
|
||||
co2EquivalentSavings: real("co2_equivalent_savings"),
|
||||
energySavings: real("energy_savings"),
|
||||
energyCostSavings: real("energy_cost_savings"),
|
||||
propertyValuationIncrease: real("property_valuation_increase"),
|
||||
rentalYieldIncrease: real("rental_yield_increase"),
|
||||
totalWorkHours: real("total_work_hours"),
|
||||
labourDays: real("labour_days"),
|
||||
alreadyInstalled: boolean("already_installed").default(false),
|
||||
});
|
||||
export const recommendation = pgTable(
|
||||
"recommendation",
|
||||
{
|
||||
id: bigserial("id", { mode: "bigint" }).primaryKey(),
|
||||
propertyId: bigint("property_id", { mode: "bigint" })
|
||||
.notNull()
|
||||
.references(() => property.id),
|
||||
createdAt: timestamp("created_at").notNull().defaultNow(),
|
||||
type: text("type").notNull(),
|
||||
measureType: text("measure_type"),
|
||||
description: text("description").notNull(),
|
||||
estimatedCost: real("estimated_cost"),
|
||||
constingencyCost: real("contingency_cost"),
|
||||
// default will indicate whether a mtaterial is currently being used in a recommendation and we will use this boolean to switch
|
||||
// between materials in the UI and switch off all materials entirely
|
||||
default: boolean("default").notNull(),
|
||||
startingUValue: real("starting_u_value"),
|
||||
newUValue: real("new_u_value"),
|
||||
sapPoints: real("sap_points"),
|
||||
heatDemand: real("heat_demand"),
|
||||
kwhSavings: real("kwh_savings"),
|
||||
co2EquivalentSavings: real("co2_equivalent_savings"),
|
||||
energySavings: real("energy_savings"),
|
||||
energyCostSavings: real("energy_cost_savings"),
|
||||
propertyValuationIncrease: real("property_valuation_increase"),
|
||||
rentalYieldIncrease: real("rental_yield_increase"),
|
||||
totalWorkHours: real("total_work_hours"),
|
||||
labourDays: real("labour_days"),
|
||||
alreadyInstalled: boolean("already_installed").default(false),
|
||||
},
|
||||
(table) => [index("recommendation_property_id_idx").on(table.propertyId)]
|
||||
);
|
||||
|
||||
export const unitQuantity: [string, ...string[]] = ["m2", "part", "kwp"];
|
||||
export const unitQuantityEnum = pgEnum("unit_quantity", unitQuantity);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue