Skip empty categories in menu API response

Only include category headers that actually have items assigned
to them, preventing empty categories from showing up in the app.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
John Mizerek 2026-01-28 22:29:38 -08:00
parent 6b31b1abcf
commit a5fa1c1041

View file

@ -300,12 +300,19 @@
<cfset rows = []>
<!--- For unified schema with Categories table, add category headers first --->
<!--- Build set of category IDs that actually have items --->
<cfset categoriesWithItems = {}>
<cfloop query="q">
<cfif q.ItemCategoryID GT 0>
<cfset categoriesWithItems[q.ItemCategoryID] = true>
</cfif>
</cfloop>
<!--- For unified schema with Categories table, add category headers (only if they have items) --->
<cfif newSchemaActive AND isDefined("qCategories")>
<cfloop query="qCategories">
<cfif structKeyExists(categoriesWithItems, qCategories.CategoryID)>
<!--- Add category as a virtual parent item --->
<!--- Use CategoryID as ItemID, and set ItemCategoryID to same value --->
<!--- Set ItemParentItemID to 0 to mark as root level --->
<cfset arrayAppend(rows, {
"ItemID": qCategories.CategoryID,
"ItemCategoryID": qCategories.CategoryID,
@ -324,6 +331,7 @@
"ItemStationName": "",
"ItemStationColor": ""
})>
</cfif>
</cfloop>
</cfif>