mirror of
https://github.com/Hestia-Homes/assessment-model.git
synced 2026-06-08 11:37:25 +00:00
save filter sanity - make it look pretty
This commit is contained in:
parent
c9bfb0ce9c
commit
92be2f1e5a
4 changed files with 14 additions and 26 deletions
|
|
@ -17,7 +17,7 @@ export async function POST(req: NextRequest) {
|
|||
console.log("filters", filters);
|
||||
const properties = await getProperties(
|
||||
portfolioId,
|
||||
1000,
|
||||
10000,
|
||||
0,
|
||||
filters
|
||||
);
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ export default function PropertyFilters({
|
|||
epcIndex(epc) <= epcIndex(expectedEpc)
|
||||
}
|
||||
>
|
||||
{epc} or worse
|
||||
{epc} or below
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
|
|
@ -128,7 +128,7 @@ export default function PropertyFilters({
|
|||
epcIndex(epc) >= epcIndex(currentEpc)
|
||||
}
|
||||
>
|
||||
{epc} or better
|
||||
{epc} or above
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ export function parsePropertyFilters(
|
|||
parsed.push({
|
||||
field: "expectedEpc",
|
||||
operator: "epc_at_least",
|
||||
value: filters.expected_epc_at_least.toUpperCase(),
|
||||
value: filters.expected_epc_at_least,
|
||||
});
|
||||
}
|
||||
console.log(parsed)
|
||||
|
|
|
|||
|
|
@ -457,32 +457,20 @@ export async function getProperties(
|
|||
break;
|
||||
}
|
||||
case "expectedEpc": {
|
||||
const minSap =
|
||||
EPC_TO_SAP_MIN[filter.value as keyof typeof EPC_TO_SAP_MIN];
|
||||
if (minSap === undefined) break;
|
||||
|
||||
if (filter.operator === "epc_at_least") {
|
||||
whereClauses.push(sql`
|
||||
CASE t.epc::text
|
||||
WHEN 'A' THEN 7
|
||||
WHEN 'B' THEN 6
|
||||
WHEN 'C' THEN 5
|
||||
WHEN 'D' THEN 4
|
||||
WHEN 'E' THEN 3
|
||||
WHEN 'F' THEN 2
|
||||
WHEN 'G' THEN 1
|
||||
END
|
||||
>=
|
||||
CASE ${filter.value}
|
||||
WHEN 'A' THEN 7
|
||||
WHEN 'B' THEN 6
|
||||
WHEN 'C' THEN 5
|
||||
WHEN 'D' THEN 4
|
||||
WHEN 'E' THEN 3
|
||||
WHEN 'F' THEN 2
|
||||
WHEN 'G' THEN 1
|
||||
END
|
||||
`);
|
||||
whereClauses.push(
|
||||
sql`
|
||||
pl.post_sap_points IS NOT NULL
|
||||
AND pl.post_sap_points >= ${minSap}
|
||||
`
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue