Merge pull request #148 from Hestia-Homes/new-reporting

Added recommendations index
This commit is contained in:
KhalimCK 2025-12-11 04:42:39 +08:00 committed by GitHub
commit fb342d0955
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 4852 additions and 28 deletions

View file

@ -0,0 +1 @@
CREATE INDEX "recommendation_property_id_idx" ON "recommendation" USING btree ("property_id");

File diff suppressed because it is too large Load diff

View file

@ -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
}
]
}

View file

@ -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);