- Add queryTimed() wrapper and logPerf() for per-endpoint timing metrics - Add api_perf_log table flush mechanism with background thread batching - Add application-scope cache (appCacheGet/Put/Invalidate) with TTL - Cache businesses/get (5m), addresses/states (24h), menu/items (2m) - Fix N+1 queries in orders/history, orders/listForKDS (batch fetch) - Fix correlated subquery in orders/getDetail (LEFT JOIN) - Combine 4 queries into 1 in portal/stats (subselects) - Optimize getForBuilder tree building with pre-indexed parent lookup - Add cache invalidation in update, saveBrandColor, updateHours, saveFromBuilder - New admin/perf.cfm dashboard (localhost-protected) - Instrument top 10 endpoints with queryTimed + logPerf Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
43 lines
1.1 KiB
Text
43 lines
1.1 KiB
Text
<cfsetting showdebugoutput="false">
|
|
<cfsetting enablecfoutputonly="true">
|
|
<cfcontent type="application/json; charset=utf-8">
|
|
|
|
<!--- List US states for address forms (cached 24h - static data) --->
|
|
<cfscript>
|
|
try {
|
|
cached = appCacheGet("states", 86400);
|
|
if (!isNull(cached)) {
|
|
writeOutput(cached);
|
|
abort;
|
|
}
|
|
|
|
qStates = queryExecute("
|
|
SELECT tt_StateID as StateID, tt_StateAbbreviation as StateAbbreviation, tt_StateName as StateName
|
|
FROM tt_States
|
|
ORDER BY tt_StateName
|
|
", {}, { datasource: "payfrit" });
|
|
|
|
states = [];
|
|
for (row in qStates) {
|
|
arrayAppend(states, {
|
|
"StateID": row.StateID,
|
|
"Abbr": row.StateAbbreviation,
|
|
"Name": row.StateName
|
|
});
|
|
}
|
|
|
|
jsonResponse = serializeJSON({
|
|
"OK": true,
|
|
"STATES": states
|
|
});
|
|
appCachePut("states", jsonResponse);
|
|
writeOutput(jsonResponse);
|
|
|
|
} catch (any e) {
|
|
writeOutput(serializeJSON({
|
|
"OK": false,
|
|
"ERROR": "server_error",
|
|
"MESSAGE": e.message
|
|
}));
|
|
}
|
|
</cfscript>
|