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/clearLocalCoffee.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

49 lines
1.7 KiB
Text

<cfsetting showdebugoutput="false">
<cfsetting enablecfoutputonly="true">
<cfcontent type="application/json; charset=utf-8" reset="true">
<cfscript>
response = { "OK": false, "steps": [] };
try {
// Business IDs to delete (Lo/Cal Coffee and SANTA MONICA entries)
businessIDs = [38, 39, 40, 41, 42];
for (bizID in businessIDs) {
// Delete lt_ItemID_TemplateItemID for items belonging to this business
queryTimed("
DELETE itl FROM lt_ItemID_TemplateItemID itl
INNER JOIN Items i ON i.ID = itl.ItemID
WHERE i.BusinessID = :bizID
", { bizID: bizID }, { datasource: "payfrit" });
// Delete Items
queryTimed("DELETE FROM Items WHERE BusinessID = :bizID", { bizID: bizID }, { datasource: "payfrit" });
// Delete Categories
queryTimed("DELETE FROM Categories WHERE BusinessID = :bizID", { bizID: bizID }, { datasource: "payfrit" });
// Delete Hours
queryTimed("DELETE FROM Hours WHERE BusinessID = :bizID", { bizID: bizID }, { datasource: "payfrit" });
// Delete Addresses linked to this business
queryTimed("DELETE FROM Addresses WHERE BusinessID = :bizID", { bizID: bizID }, { datasource: "payfrit" });
// Delete the Business itself
queryTimed("DELETE FROM Businesses WHERE ID = :bizID", { bizID: bizID }, { datasource: "payfrit" });
response.steps.append("Deleted business " & bizID & " and all related data");
}
response.OK = true;
response.message = "Cleared all Lo/Cal Coffee and SANTA MONICA businesses";
} catch (any e) {
response.error = e.message;
if (len(e.detail)) {
response.detail = e.detail;
}
}
writeOutput(serializeJSON(response));
</cfscript>