Added energy assessments table

This commit is contained in:
Khalim Conn-Kowlessar 2024-07-25 18:28:42 +01:00
parent 89c63c6f42
commit e50b159d6a
6 changed files with 2777 additions and 2 deletions

View file

@ -0,0 +1,115 @@
CREATE TABLE IF NOT EXISTS "energy_assessments" (
"id" bigserial PRIMARY KEY NOT NULL,
"uprn" bigint NOT NULL,
"uprn_source" text NOT NULL,
"property_type" text NOT NULL,
"building_reference_number" text,
"current_energy_efficiency" text NOT NULL,
"current_energy_rating" text NOT NULL,
"address1" text NOT NULL,
"address2" text NOT NULL,
"address3" text,
"posttown" text NOT NULL,
"postcode" text NOT NULL,
"address" text NOT NULL,
"county" text[],
"constituency" text,
"constituency_label" text,
"low_energy_fixed_light_count" text NOT NULL,
"construction_age_band" text NOT NULL,
"mainheat_energy_eff" text NOT NULL,
"windows_env_eff" text NOT NULL,
"lighting_energy_eff" text NOT NULL,
"environmentImpactPotential" text NOT NULL,
"mainheatcont_description" text NOT NULL,
"sheating_energy_eff" text NOT NULL,
"local_authority" text NOT NULL,
"local_authority_label" text NOT NULL,
"fixed_lighting_outlets_count" text NOT NULL,
"energy_tariff" text NOT NULL,
"mechanical_ventilation" text NOT NULL,
"solar_water_heating_flag" text NOT NULL,
"co2_emissions_potential" text NOT NULL,
"number_heated_rooms" text NOT NULL,
"floor_description" text NOT NULL,
"energy_consumption_potential" text NOT NULL,
"built_form" text NOT NULL,
"number_open_fireplaces" text NOT NULL,
"windows_description" text NOT NULL,
"glazed_area" text NOT NULL,
"inspection_date" timestamp (6) with time zone NOT NULL,
"mains_gas_flag" text NOT NULL,
"co2_emiss_curr_per_floor_area" text NOT NULL,
"heat_loss_corridor" text NOT NULL,
"unheated_corridor_length" text,
"flat_storey_count" text,
"roof_energy_eff" text NOT NULL,
"total_floor_area" text NOT NULL,
"environment_impact_current" text NOT NULL,
"roof_description" text NOT NULL,
"floor_energy_eff" text NOT NULL,
"number_habitable_rooms" text NOT NULL,
"hot_water_env_eff" text NOT NULL,
"mainheatc_energy_eff" text NOT NULL,
"main_fuel" text NOT NULL,
"lighting_env_eff" text NOT NULL,
"windows_energy_eff" text NOT NULL,
"floor_env_eff" text NOT NULL,
"sheating_env_eff" text NOT NULL,
"lighting_description" text NOT NULL,
"roof_env_eff" text NOT NULL,
"walls_energy_eff" text NOT NULL,
"photo_supply" text NOT NULL,
"lighting_cost_potential" text NOT NULL,
"mainheat_env_eff" text NOT NULL,
"multi_glaze_proportion" text NOT NULL,
"main_heating_controls" text NOT NULL,
"flat_top_storey" text,
"secondheat_description" text NOT NULL,
"walls_env_eff" text NOT NULL,
"transaction_type" text NOT NULL,
"extension_count" text NOT NULL,
"mainheatc_env_eff" text NOT NULL,
"lmk_key" text,
"wind_turbine_count" text NOT NULL,
"tenure" text NOT NULL,
"floor_level" text NOT NULL,
"potential_energy_efficiency" text NOT NULL,
"potential_energy_rating" text NOT NULL,
"hot_water_energy_eff" text NOT NULL,
"low_energy_lighting" text NOT NULL,
"walls_description" text NOT NULL,
"hotwater_description" text NOT NULL,
"co2_emissions_current" text NOT NULL,
"heating_cost_current" text NOT NULL,
"heating_cost_potential" text NOT NULL,
"hot_water_cost_current" text NOT NULL,
"hot_water_cost_potential" text NOT NULL,
"lighting_cost_current" text NOT NULL,
"energy_consumption_current" text NOT NULL,
"lodgement_date" timestamp (6) with time zone NOT NULL,
"lodgement_datetime" timestamp (6) with time zone NOT NULL,
"mainheat_description" text NOT NULL,
"floor_height" real NOT NULL,
"glazed_type" text NOT NULL,
"file_location" text NOT NULL,
"surveyor_name" text NOT NULL,
"surveyor_company" text NOT NULL,
"space_heating_kwh" text NOT NULL,
"water_heating_kwh" text NOT NULL,
"number_of_doors" integer NOT NULL,
"number_of_insulated_doors" integer NOT NULL,
"number_of_floors" integer NOT NULL,
"insulation_wall_area" real NOT NULL,
"heat_loss_perimeter" real NOT NULL,
"party_wall_length" real NOT NULL,
"perimeter" real NOT NULL,
"rooms_with_bath_and_or_shower" integer,
"rooms_with_mixer_shower_no_bath" integer,
"room_with_bath_and_mixer_shower" integer,
"percent_draftproofed" integer,
"has_hot_water_cylinder" boolean,
"cylinder_insulation_type" text,
"cylinder_insulation_thickness" integer,
"cylinder_thermostat" boolean
);

File diff suppressed because it is too large Load diff

View file

@ -526,6 +526,13 @@
"when": 1720629405710,
"tag": "0074_regular_blonde_phantom",
"breakpoints": true
},
{
"idx": 75,
"version": "5",
"when": 1721928302758,
"tag": "0075_even_phalanx",
"breakpoints": true
}
]
}

View file

@ -0,0 +1,141 @@
import {
bigserial,
text,
timestamp,
pgTable,
real,
pgEnum,
integer,
bigint,
boolean,
} from "drizzle-orm/pg-core";
import { InferModel } from "drizzle-orm";
// Define the table
export const energyAssessment = pgTable("energy_assessments", {
id: bigserial("id", { mode: "bigint" }).primaryKey(),
uprn: bigint("uprn", { mode: "bigint" }).notNull(),
uprnSource: text("uprn_source").notNull(),
propertyType: text("property_type").notNull(),
buildingReferenceNumber: text("building_reference_number"),
currentEnergyEfficiency: text("current_energy_efficiency").notNull(),
currentEnergyRating: text("current_energy_rating").notNull(),
address1: text("address1").notNull(),
address2: text("address2").notNull(),
address3: text("address3"),
posttown: text("posttown").notNull(),
postcode: text("postcode").notNull(),
address: text("address").notNull(),
county: text("county").array(),
constituency: text("constituency"),
constituencyLabel: text("constituency_label"),
lowEnergyFixedLightCount: text("low_energy_fixed_light_count").notNull(),
constructionAgeBand: text("construction_age_band").notNull(),
mainheatEnergyEff: text("mainheat_energy_eff").notNull(),
windowsEnvEff: text("windows_env_eff").notNull(),
lightingEnergyEff: text("lighting_energy_eff").notNull(),
environmentImpactPotential: text("environmentImpactPotential").notNull(),
mainheatcontDescription: text("mainheatcont_description").notNull(),
sheatingEnergyEff: text("sheating_energy_eff").notNull(),
localAuthority: text("local_authority").notNull(),
localAuthorityLabel: text("local_authority_label").notNull(),
fixedLightingOutletsCount: text("fixed_lighting_outlets_count").notNull(),
energyTariff: text("energy_tariff").notNull(),
mechanicalVentilation: text("mechanical_ventilation").notNull(),
solarWaterHeatingFlag: text("solar_water_heating_flag").notNull(),
co2EmissionsPotential: text("co2_emissions_potential").notNull(),
numberHeatedRooms: text("number_heated_rooms").notNull(),
floorDescription: text("floor_description").notNull(),
energyConsumptionPotential: text("energy_consumption_potential").notNull(),
builtForm: text("built_form").notNull(),
numberOpenFireplaces: text("number_open_fireplaces").notNull(),
windowsDescription: text("windows_description").notNull(),
glazedArea: text("glazed_area").notNull(),
inspectionDate: timestamp("inspection_date", {
precision: 6,
withTimezone: true,
}).notNull(),
mainsGasFlag: text("mains_gas_flag").notNull(),
co2EmissCurrPerFloorArea: text("co2_emiss_curr_per_floor_area").notNull(),
heatLossCorridor: text("heat_loss_corridor").notNull(),
unheatedCorridorLength: text("unheated_corridor_length"),
flatStoreyCount: text("flat_storey_count"),
roofEnergyEff: text("roof_energy_eff").notNull(),
totalFloorArea: text("total_floor_area").notNull(),
environmentImpactCurrent: text("environment_impact_current").notNull(),
roofDescription: text("roof_description").notNull(),
floorEnergyEff: text("floor_energy_eff").notNull(),
numberHabitableRooms: text("number_habitable_rooms").notNull(),
hotWaterEnvEff: text("hot_water_env_eff").notNull(),
mainheatcEnergyEff: text("mainheatc_energy_eff").notNull(),
mainFuel: text("main_fuel").notNull(),
lightingEnvEff: text("lighting_env_eff").notNull(),
windowsEnergyEff: text("windows_energy_eff").notNull(),
floorEnvEff: text("floor_env_eff").notNull(),
sheatingEnvEff: text("sheating_env_eff").notNull(),
lightingDescription: text("lighting_description").notNull(),
roofEnvEff: text("roof_env_eff").notNull(),
wallsEnergyEff: text("walls_energy_eff").notNull(),
photoSupply: text("photo_supply").notNull(),
lightingCostPotential: text("lighting_cost_potential").notNull(),
mainheatEnvEff: text("mainheat_env_eff").notNull(),
multiGlazeProportion: text("multi_glaze_proportion").notNull(),
mainHeatingControls: text("main_heating_controls").notNull(),
flatTopStorey: text("flat_top_storey"),
secondheatDescription: text("secondheat_description").notNull(),
wallsEnvEff: text("walls_env_eff").notNull(),
transactionType: text("transaction_type").notNull(),
extensionCount: text("extension_count").notNull(),
mainheatcEnvEff: text("mainheatc_env_eff").notNull(),
lmkKey: text("lmk_key"),
windTurbineCount: text("wind_turbine_count").notNull(),
tenure: text("tenure").notNull(),
floorLevel: text("floor_level").notNull(),
potentialEnergyEfficiency: text("potential_energy_efficiency").notNull(),
potentialEnergyRating: text("potential_energy_rating").notNull(),
hotWaterEnergyEff: text("hot_water_energy_eff").notNull(),
lowEnergyLighting: text("low_energy_lighting").notNull(),
wallsDescription: text("walls_description").notNull(),
hotwaterDescription: text("hotwater_description").notNull(),
co2EmissionsCurrent: text("co2_emissions_current").notNull(),
heatingCostCurrent: text("heating_cost_current").notNull(),
heatingCostPotential: text("heating_cost_potential").notNull(),
hotWaterCostCurrent: text("hot_water_cost_current").notNull(),
hotWaterCostPotential: text("hot_water_cost_potential").notNull(),
lightingCostCurrent: text("lighting_cost_current").notNull(),
energyConsumptionCurrent: text("energy_consumption_current").notNull(),
lodgementDate: timestamp("lodgement_date", {
precision: 6,
withTimezone: true,
}).notNull(),
lodgementDatetime: timestamp("lodgement_datetime", {
precision: 6,
withTimezone: true,
}).notNull(),
mainheatDescription: text("mainheat_description").notNull(),
floorHeight: real("floor_height").notNull(),
glazedType: text("glazed_type").notNull(),
fileLocation: text("file_location").notNull(),
surveyorName: text("surveyor_name").notNull(),
surveyorCompany: text("surveyor_company").notNull(),
spaceHeatingKwh: text("space_heating_kwh").notNull(),
waterHeatingKwh: text("water_heating_kwh").notNull(),
numberOfDoors: integer("number_of_doors").notNull(),
numberOfInsulatedDoors: integer("number_of_insulated_doors").notNull(),
numberOfFloors: integer("number_of_floors").notNull(),
insulationWallArea: real("insulation_wall_area").notNull(),
heatLossPerimeter: real("heat_loss_perimeter").notNull(),
partyWallLength: real("party_wall_length").notNull(),
perimeter: real("perimeter").notNull(),
roomsWithBathAndOrShower: integer("rooms_with_bath_and_or_shower"),
roomsWithMixerShowerNoBath: integer("rooms_with_mixer_shower_no_bath"),
roomWithBathAndMixerShower: integer("room_with_bath_and_mixer_shower"),
percentDraftproofed: integer("percent_draftproofed"),
hasHotWaterCylinder: boolean("has_hot_water_cylinder"),
cylinderInsulationType: text("cylinder_insulation_type"),
cylinderInsulationThickness: integer("cylinder_insulation_thickness"),
cylinderThermostat: boolean("cylinder_thermostat"),
});
// Types for the new table
export type EnergyAssessment = InferModel<typeof energyAssessment, "select">;

View file

@ -9,6 +9,8 @@ export default async function Recommendations({
const propertyMeta = await getPropertyMeta(params.propertyId);
const recommendations = await getRecommendations(params.planId);
console.log(recommendations);
return (
<div className="leading-loose tracking-wider">
<div className="flex py-8 text-lg">Recommendations</div>

View file

@ -1,8 +1,8 @@
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
// "target": "es5",
"target": "ESNext",
"target": "es5",
// "target": "ESNext",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,