This repository has been archived on 2026-03-21. You can view files and clone it, but cannot push or open issues or pull requests.
payfrit-biz/api/orders/debugLineItems.cfm
John 16a3b7c9a3 Replace queryExecute with queryTimed across all endpoints for perf tracking
Converts 200+ endpoint files to use queryTimed() wrapper which tracks
DB query count and execution time. Restores perf dashboard files that
were accidentally moved to _scripts/. Includes portal UI updates.
2026-02-02 00:28:37 -08:00

63 lines
1.6 KiB
Text

<cfsetting showdebugoutput="false">
<cfsetting enablecfoutputonly="true">
<cfparam name="url.orderid" default="0">
<cfset orderId = val(url.orderid)>
<cfif orderId LTE 0>
<cfcontent type="application/json; charset=utf-8">
<cfoutput>{"OK": false, "ERROR": "Please provide orderid in URL: ?orderid=300"}</cfoutput>
<cfabort>
</cfif>
<cftry>
<cfset qLineItems = queryTimed("
SELECT
oli.ID,
oli.ParentOrderLineItemID,
oli.ItemID,
oli.Price,
oli.Quantity,
oli.Remark,
oli.IsDeleted,
i.Name,
i.ParentItemID
FROM OrderLineItems oli
INNER JOIN Items i ON i.ID = oli.ItemID
WHERE oli.OrderID = ?
ORDER BY oli.ID
", [ { value = orderId, cfsqltype = "cf_sql_integer" } ], { datasource = "payfrit" })>
<cfset lineItems = []>
<cfloop query="qLineItems">
<cfset arrayAppend(lineItems, {
"OrderLineItemID": qLineItems.ID,
"ParentOrderLineItemID": qLineItems.ParentOrderLineItemID,
"ItemID": qLineItems.ID,
"Price": qLineItems.Price,
"Quantity": qLineItems.Quantity,
"Remark": qLineItems.Remark,
"IsDeleted": qLineItems.IsDeleted,
"Name": qLineItems.Name,
"ParentItemID": qLineItems.ParentItemID
})>
</cfloop>
<cfcontent type="application/json; charset=utf-8">
<cfoutput>#serializeJSON({
"OK": true,
"OrderID": orderId,
"TotalLineItems": arrayLen(lineItems),
"LineItems": lineItems
})#</cfoutput>
<cfcatch>
<cfcontent type="application/json; charset=utf-8">
<cfoutput>#serializeJSON({
"OK": false,
"ERROR": "db_error",
"MESSAGE": cfcatch.message
})#</cfoutput>
</cfcatch>
</cftry>