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/admin/_scripts/debugTemplateLinks.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

47 lines
1.4 KiB
Text

<cfsetting showdebugoutput="false">
<cfsetting enablecfoutputonly="true">
<cfcontent type="application/json; charset=utf-8" reset="true">
<cfscript>
// Check lt_ItemID_TemplateItemID for Big Dean's (BusinessID 27)
bizId = 27;
// Count total links
qCount = queryTimed("SELECT COUNT(*) as cnt FROM lt_ItemID_TemplateItemID", {}, { datasource: "payfrit" });
// Get template item IDs for this business
qTemplates = queryTimed("
SELECT DISTINCT tl.TemplateItemID, i.Name
FROM lt_ItemID_TemplateItemID tl
JOIN Items i ON i.ID = tl.TemplateItemID
WHERE i.BusinessID = :bizId
", { bizId: bizId }, { datasource: "payfrit" });
templates = [];
for (row in qTemplates) {
arrayAppend(templates, { "TemplateItemID": row.TemplateItemID, "Name": row.Name });
}
// Get items that should be categories (ParentItemID=0, not templates)
qCategories = queryTimed("
SELECT i.ID, i.Name, i.ParentItemID, i.IsCollapsible
FROM Items i
WHERE i.BusinessID = :bizId
AND i.ParentItemID = 0
AND i.IsCollapsible = 0
AND NOT EXISTS (SELECT 1 FROM lt_ItemID_TemplateItemID tl WHERE tl.TemplateItemID = i.ID)
ORDER BY i.SortOrder
", { bizId: bizId }, { datasource: "payfrit" });
categories = [];
for (row in qCategories) {
arrayAppend(categories, { "ItemID": row.ID, "Name": row.Name });
}
writeOutput(serializeJSON({
"OK": true,
"totalTemplateLinks": qCount.cnt,
"templatesForBusiness": templates,
"categoriesForBusiness": categories
}));
</cfscript>