Skip to content

Commit

Permalink
Merge branch 'main' of github.com:codeforboston/home-energy-analysis-…
Browse files Browse the repository at this point in the history
…tool into schema-prisma-124-v2
  • Loading branch information
ethanstrominger committed Nov 11, 2024
2 parents 5c7d610 + 6bde273 commit ca47512
Show file tree
Hide file tree
Showing 111 changed files with 9,694 additions and 15,155 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/heat-stack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"python.testing.pytestArgs": [
"rules-engine"
"python"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
File renamed without changes
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { type z } from 'zod'
import { type HeatLoadAnalysisZod } from '#types/index'

type HeatLoadAnalysisZod = z.infer<typeof HeatLoadAnalysisZod>
export function AnalysisHeader(props: { usage_data: any }) {
import { type z } from 'zod';
import { type UsageDataSchema } from '#/types/types.ts';
import HelpCircle from './assets/help-circle.svg'

export function AnalysisHeader({ usage_data }: { usage_data: UsageDataSchema}) {
// Example usage_data
// new Map([[
// "estimated_balance_point",
Expand Down Expand Up @@ -34,78 +33,86 @@ export function AnalysisHeader(props: { usage_data: any }) {
// 3312125.0171753373
// ]])

const summaryOutputs = props.usage_data?.get('summary_output')
// Extract the summary_output from usage_data
const summaryOutputs = usage_data?.summary_output;

const totalRecords = usage_data?.billing_records?.length || "-"

// Calculate the number of billing periods included in Heating calculations
const heatingAnalysisTypeRecords = props.usage_data
?.get('billing_records')
?.filter((billingRecord: any) => billingRecord.get('analysis_type') == 1)
const heatingAnalysisTypeRecords = usage_data?.billing_records?.filter(
(billingRecord) => billingRecord.analysis_type === 1,
// Do wee need this code instead? (billingRecord) => billingRecord.analysis_type !== "NOT_ALLOWED_IN_CALCULATIONS",
);

const recordsIncludedByDefault = heatingAnalysisTypeRecords?.filter(
(billingRecord: any) =>
billingRecord.get('default_inclusion_by_calculation') == true &&
billingRecord.get('inclusion_override') == false,
).length
(billingRecord) =>
billingRecord.default_inclusion_by_calculation === true &&
billingRecord.inclusion_override === false,
).length;

const recordsIncludedByOverride = heatingAnalysisTypeRecords?.filter(
(billingRecord: any) =>
billingRecord.get('default_inclusion_by_calculation') == false &&
billingRecord.get('inclusion_override') == true,
).length
(billingRecord) =>
billingRecord.default_inclusion_by_calculation === false &&
billingRecord.inclusion_override === true,
).length;

const numRecordsForHeatingCalculations =
recordsIncludedByDefault + recordsIncludedByOverride
(recordsIncludedByDefault || 0) + (recordsIncludedByOverride || 0);


return (
<div className="section-title">
<div className="item-group-title">Heat Load Analysis</div>
<div className="flex flex-row">
<div className="section-title mt-12">
<div className="flex flex-row gap-0.5 mb-4">
<div className="item-group-title font-semibold text-2xl">Heat Load Analysis</div>
{/* TODO: add help text here */}
{/* <img src={HelpCircle} alt='help text'/> */}
</div>

<div className="flex flex-row gap-x-4">
<div className="basis-1/3">
<div className="item-title-small">
<div className="item-title-small text-xl text-slate-700 font-normal">
Average Indoor Temperature <br />
<div className="item">
{summaryOutputs?.get('average_indoor_temperature')} °F
</div>{' '}
<div className="item font-bold">
{summaryOutputs?.average_indoor_temperature} °F
</div>
<br />
Balance Point Temperature
<br />
<div className="item">
{summaryOutputs?.get('estimated_balance_point')} °F
</div>{' '}
<div className="item font-bold">
{summaryOutputs?.estimated_balance_point} °F
</div>
<br />
</div>
</div>
<div className="basis-1/3">
<div className="item-title-small">
<div className="item-title-small text-xl text-slate-700 font-normal">
Number of Periods Included <br />
<div className="item">{numRecordsForHeatingCalculations}</div>
<div className="item font-bold">{numRecordsForHeatingCalculations} / {totalRecords}</div>
<br />
Daily non-heating Usage <br />
<div className="item">
<div className="item font-bold">
{/* Rounding to two decimal places */}
{summaryOutputs?.get('other_fuel_usage').toFixed(2)} therms
</div>{' '}
{summaryOutputs?.other_fuel_usage?.toFixed(2)} therms
</div>
</div>
</div>
<div className="basis-1/3">
<div className="item-title-small">
<div className="item-title-small text-xl text-slate-700 font-normal">
Standard Deviation of UA <br />
<div className="item">
<div className="item font-bold">
{/* Rounding to two decimal places */}
{(
summaryOutputs?.get('standard_deviation_of_heat_loss_rate') *
100
).toFixed(2)}{' '}
summaryOutputs?.standard_deviation_of_heat_loss_rate * 100
)?.toFixed(2)}{' '}
%
</div>{' '}
</div>
<br />
Whole-home UA
<br />
<div className="item">
<div className="item font-bold">
{/* Rounding to zero decimal places */}
{summaryOutputs?.get('whole_home_heat_loss_rate').toFixed(0)}{' '}
BTU/h-°F
</div>{' '}
{summaryOutputs?.whole_home_heat_loss_rate?.toFixed(0)} BTU/h-°F
</div>
<br />
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Upload } from 'lucide-react'
import { Suspense, /* lazy */ } from 'react'

import { Button } from '#/app/components/ui/button.tsx'
import { type UsageDataSchema } from '#/types/types.ts';
import { AnalysisHeader } from './AnalysisHeader.tsx'
import { EnergyUseHistoryChart } from './EnergyUseHistoryChart.tsx'

Expand All @@ -11,40 +11,46 @@ import { EnergyUseHistoryChart } from './EnergyUseHistoryChart.tsx'
// import { Input } from '#/app/components/ui/input.tsx'
// import { Label } from '#/app/components/ui/label.tsx'


// export function EnergyUseHistory(props: EnergyUseProps) {
export function EnergyUseHistory(props: { usage_data: any }) {
// console.log(`EnergyUseHistory:`, props.usage_data);
export function EnergyUseHistory({
usage_data,
}: {
usage_data: UsageDataSchema
}) {
const titleClass = 'text-5xl font-extrabold tracking-wide mt-10'
// const subtitleClass = 'text-2xl font-semibold text-zinc-950 mt-9'

return (

<div>
<h2 className={`${titleClass} pb-6`}>Energy Use History</h2>
<div>
<Suspense fallback={'<div>Blah</div>'}>
<input
id="energy_use_upload"
aria-label="Upload your energy billing company's bill."
//onChange
accept=".xml,.csv,application/xml,text/xml,text/csv,application/csv,application/x-csv,text/comma-separated-values,text/x-comma-separated-values"
name="energy_use_upload"
type="file"
/>
<Button type="submit"> <Upload className="h-4 w-4 mr-2" /> Upload</Button>
</Suspense>
(<a className="inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80 gap-1" href="https://github.com/codeforboston/home-energy-analysis-tool/issues/162#issuecomment-2246594484">Get example file here</a>)

</div>
{props.usage_data && <AnalysisHeader usage_data={ props.usage_data } /> }
{props.usage_data && <EnergyUseHistoryChart usage_data={props.usage_data} />}

<input
id="energy_use_upload"
aria-label="Upload your energy billing company's bill."
accept=".xml,.csv,application/xml,text/xml,text/csv,application/csv,application/x-csv,text/comma-separated-values,text/x-comma-separated-values"
name="energy_use_upload"
type="file"
/>
<Button type="submit">
<Upload className="mr-2 h-4 w-4" /> Upload
</Button>

<a
className="inline-flex items-center gap-1 rounded-md border border-transparent bg-secondary px-2.5 py-0.5 text-xs font-semibold text-secondary-foreground transition-colors hover:bg-secondary/80 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2"
href="https://github.com/codeforboston/home-energy-analysis-tool/issues/162#issuecomment-2246594484"
>
Get example file here
</a>

{usage_data && (
<>
<AnalysisHeader usage_data={usage_data} />
<EnergyUseHistoryChart usage_data={usage_data} />
</>
)}
</div>
)
}



// const file = event.target.files?.[0]

// if (file) {
Expand Down
Loading

0 comments on commit ca47512

Please sign in to comment.