Commit graph

144 commits

Author SHA1 Message Date
John Mizerek
bffca643b5 Restore API performance tracking and fix perf dashboard
- Add queryTimed(), logPerf(), flushPerfBuffer() to environment.cfm
- Auto-create ApiPerfLogs table on first flush
- Hook logPerf into Application.cfm apiAbort for automatic tracking
- Initialize request perf counters in Application.cfm
- Remove local apiAbort() overrides from 7 endpoints
- Instrument 12 high-traffic endpoints with logPerf calls
- Buffer metrics in application scope, batch INSERT every 100 requests
- 30-day auto-cleanup with probabilistic trigger

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 17:04:12 -08:00
John Mizerek
1210249f54 Normalize database column and table names across entire codebase
Update all SQL queries, query result references, and ColdFusion code to match
the renamed database schema. Tables use plural CamelCase, PKs are all `ID`,
column prefixes stripped (e.g. BusinessName→Name, UserFirstName→FirstName).

Key changes:
- Strip table-name prefixes from all column references (Businesses, Users,
  Addresses, Hours, Menus, Categories, Items, Stations, Orders,
  OrderLineItems, Tasks, TaskCategories, TaskRatings, QuickTaskTemplates,
  ScheduledTaskDefinitions, ChatMessages, Beacons, ServicePoints, Employees,
  VisitorTrackings, ApiPerfLogs, tt_States, tt_Days, tt_AddressTypes,
  tt_OrderTypes, tt_TaskTypes)
- Rename PK references from {TableName}ID to ID in all queries
- Rewrite 7 admin beacon files to use ServicePoints.BeaconID instead of
  dropped lt_Beacon_Businesses_ServicePoints link table
- Rewrite beacon assignment files (list, save, delete) for new schema
- Fix FK references incorrectly changed to ID (OrderLineItems.OrderID,
  Categories.MenuID, Tasks.CategoryID, ServicePoints.BeaconID)
- Update Addresses: AddressLat→Latitude, AddressLng→Longitude
- Update Users: UserPassword→Password, UserIsEmailVerified→IsEmailVerified,
  UserIsActive→IsActive, UserBalance→Balance, etc.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 15:39:12 -08:00
John Mizerek
dc9db32b58 Add API performance profiling, caching, and query optimizations
- 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>
2026-01-29 20:41:27 -08:00
John Mizerek
a5fa1c1041 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>
2026-01-28 22:29:38 -08:00
John Mizerek
6b31b1abcf Remove time-based filtering from customer menu API
Always return all active menus in the response so chip selector
always appears. Show all items from all menus by default instead
of filtering by current time, which caused empty results outside
menu hours.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 22:18:10 -08:00
John Mizerek
3b48c3331d Add menu list and MenuID filter to items.cfm API
Returns active menus in response so mobile apps can show menu
selector chips. Accepts optional MenuID param to filter items
to a specific menu.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 20:54:37 -08:00
John Mizerek
9091461079 Auto-select active menu based on current time, allow manual override
When multiple menus exist, checks current time and day against menu
schedules. If exactly one menu matches, auto-selects it. If times
overlap or none match, shows all categories. User can still manually
select any menu or 'All Menus' from the dropdown.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 18:13:44 -08:00
John Mizerek
41ef1631ef Allow menu deletion when categories exist - unassign instead of block
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 18:01:51 -08:00
John Mizerek
3613776ff3 Fix undefined menuName in saveWizard when using provided menuId
The menuName variable was only defined in the else branch (new menu
creation) but referenced later in category logging. Now looks up the
menu name from DB when using a provided menuId.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 17:54:16 -08:00
John Mizerek
8086065d38 Fix MenuID key case: Lucee 7 preserves case, not MENUID
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 17:48:03 -08:00
John Mizerek
61c10d9175 Use sessionStorage instead of URL params for wizard menu context
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 17:36:46 -08:00
John Mizerek
ec6bfdd9c9 Fix menu save: javaCast null breaks variable access in Lucee 7
javaCast('null','') makes the variable truly undefined, causing
'variable doesn't exist' errors when referenced in query params.
Use empty string + len() check instead.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 17:33:21 -08:00
John Mizerek
2fc30b8568 Fix add-menu wizard: skip hours validation, show menu name, hide irrelevant sections
- Pass menuName in redirect URL from menu-builder
- Show menu name in wizard header and final review
- Skip hours validation in both JS and backend for add-menu mode
- Hide menu name, hours, and community meal fields in final step
- Add id to community meal card for toggling

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 17:19:55 -08:00
John Mizerek
02a19f52be Add menu wizard flow: redirect to setup wizard after creating a new menu
When a new menu is created in Manage Menus, the user is now redirected
to the setup wizard with businessId and menuId params. The wizard skips
business info/header steps and goes straight to photo upload + category
extraction. Backend uses the provided menuId instead of creating a new
menu. Also removes temp debug from menus.cfm.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 17:08:31 -08:00
John Mizerek
65cf855ade Add menu/menus.cfm to public paths so menu save works
The endpoint was missing from the public paths whitelist in
Application.cfm, causing all requests to fail with not_logged_in.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 16:57:51 -08:00
John Mizerek
df64f161f3 Add debug tagcontext to menu save error response (temporary)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 16:56:00 -08:00
John Mizerek
6b4e5cc369 Add cfsqltype hints for nullable time params in menu save
Fixes save failure when MenuStartTime/MenuEndTime are null -
Lucee couldn't determine the SQL type without explicit hints.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 16:53:34 -08:00
John Mizerek
38b13b5bd9 Fix blank Manage Menus modal by setting title/body before showing
showMenuManager() was passing arguments to showModal() which accepts
none, so the modal content was silently discarded. Now follows the
same pattern as all other modal callers in the file.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 16:39:23 -08:00
John Mizerek
c6a45f7024 Fix CFML hash escaping in brand color migration script
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 15:17:46 -08:00
John Mizerek
b75eb8530a Fix header image spec: 1200x400 not 1220x400
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 15:16:42 -08:00
John Mizerek
7bba0fb511 Add one-time script to strip # from existing brand colors
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 15:11:01 -08:00
John Mizerek
cc96d891b2 Store brand color without # prefix, normalize on output
saveBrandColor.cfm no longer prepends # before storing. API responses
(get.cfm, items.cfm, getForBuilder.cfm) prepend # if missing so
consumers always get a CSS-ready value.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 14:58:58 -08:00
John Mizerek
8f9da2fbf0 Add Manage Menus toolbar button, photo upload, and various improvements
- Move menu manager button to toolbar next to Save Menu for visibility
- Implement server-side photo upload for menu items
- Strip base64 data URLs from save payload to reduce size
- Add scheduled tasks, quick tasks, ratings, and task categories APIs
- Add vertical support and brand color features

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 14:43:41 -08:00
John Mizerek
0d3c381ed6 Add about.cfm API endpoint for mobile app About screennAdds server-side content for About Payfrit screen allowing content updates without releasing new app versions.nCo-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> 2026-01-28 00:38:58 -08:00
John Mizerek
400df7624f Simplify address API - delivery addresses only
- Remove TypeID/Label from list response
- Hardcode TypeID=2 (delivery) in add endpoint
- Filter to personal addresses only (BusinessID=0 or NULL)
- Just IsDefault flag, no home/work labels

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 00:12:18 -08:00
John Mizerek
6d5620d513 Filter out business addresses from user address list 2026-01-28 00:02:25 -08:00
John Mizerek
cadc66e46a Add address types endpoint, fix dev mode SMS skip
- Add /addresses/types.cfm - returns address types list
- Update /addresses/list.cfm - include TypeID in response
- Update /addresses/add.cfm - accept TypeID instead of hardcoded '2'
- Fix loginOTP.cfm and sendOTP.cfm to skip Twilio SMS on dev server

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 00:00:01 -08:00
John Mizerek
477cf6b8b5 Auto-login single-business users, add switch/add business links
- Skip business selection for users with only one business
- Add Switch Business and Add New Business links in portal sidebar
- Handle returning users switching businesses (token + no business)
2026-01-27 21:49:08 -08:00
John Mizerek
80aa65d7fa Fix populateBusinessSelect - remove continueBtn references
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 21:38:52 -08:00
John Mizerek
6f0229247f Fix login - remove orphaned businessForm event listener
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 21:38:08 -08:00
John Mizerek
51e979a679 Remove URL params - use localStorage for auth
- HUD reads businessId from localStorage instead of ?b= param
- Portal opens HUD/quick-tasks without URL params
- Business select auto-proceeds on selection (no button needed)
- Quick tasks reads from payfrit_portal_business localStorage

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 21:32:47 -08:00
John Mizerek
f96d8f4fe3 Update HUD default business to 47
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 21:27:45 -08:00
John Mizerek
49ef916f34 Remove demo mode from HUD, fix task creation timezone
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 21:25:05 -08:00
John Mizerek
d4cc4b4a6c Fix service bell task creation for Android app
- Update create.cfm to handle TaskTypeID for service bell tasks
- Update hud.js to prefer TaskTypeColor/TaskTypeName for task display

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 20:52:59 -08:00
John Mizerek
c5ebb24b39 Fix completeProfile.cfm syntax error
Use mail() service inside cfscript instead of cfmail tag

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 13:33:40 -08:00
John Mizerek
3ceedaa818 Show magic OTP 123456 on dev signup page
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 13:32:23 -08:00
John Mizerek
a16e8668a8 Add auth redirect to portal index
Redirects unauthenticated users to signup.html

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 13:26:30 -08:00
John Mizerek
16f63bebe5 Fix seedData.cfm: remove UserEmail column reference
Users table doesn't have email column.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 12:44:53 -08:00
John Mizerek
3a683751b8 Allow public access to /api/dev/ endpoints
Dev endpoints have their own isDevEnvironment check inside.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 12:41:26 -08:00
John Mizerek
05cf73446f Add dev environment configuration and tools
- api/config/environment.cfm: Central config for dev vs prod settings
  - Verbose errors, debug logging, magic OTP bypass
  - Rate limiting toggle, email catch-all, token expiry settings
- api/dev/: Development-only endpoints
  - seedData.cfm: Create/reset test users
  - timeTravel.cfm: Manipulate timestamps for testing
  - index.cfm: Dev tools index

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 12:39:28 -08:00
John Mizerek
8e3bb681e7 Add OTP-based signup page for website onboarding
- New portal/signup.html with phone → OTP → profile flow
- Handle both new users (signup) and existing users (login)
- Auto-detect user type and use appropriate API endpoints
- Show DEV_OTP on page for local testing
- Updated sendOTP.cfm to gracefully handle missing Twilio

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 11:49:44 -08:00
John Mizerek
ed3f9192d5 Add Task Admin feature to portal
- Add Quick Task Templates: admin creates task shortcuts, tap to create tasks instantly
- Add Scheduled Tasks: admin defines recurring tasks with cron expressions
- New API endpoints: /api/admin/quickTasks/* and /api/admin/scheduledTasks/*
- New database tables: QuickTaskTemplates, ScheduledTaskDefinitions
- Portal UI: Task Admin page with shortcut buttons and scheduled task management

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 01:51:41 -08:00
John Mizerek
43a8d18541 Update callServer task endpoint
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 01:40:41 -08:00
John Mizerek
405914c586 Fix subtotal/itemCount null handling in history API
Use val() instead of ?: for SUM results that may be empty strings

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 21:59:33 -08:00
John Mizerek
e9eb708de1 Fix null value handling in setOrderType API
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 21:41:31 -08:00
John Mizerek
d783f91075 Fix null value handling in setLineItem API
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 21:40:32 -08:00
John Mizerek
186c3fcf68 Fix null value handling in getActiveCart API
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 21:39:25 -08:00
John Mizerek
6727f42194 Fix null/empty value handling in order APIs
Wrap numeric fields with val() to prevent "can't cast empty string to number"
errors when database values are null or empty strings.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 21:30:13 -08:00
John Mizerek
5f3f5a7345 Enable address endpoints and switch Stripe to live mode
- Add address list/add/delete/setDefault to public endpoint allowlist
- Switch Stripe from test to live mode for production payments

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 21:26:14 -08:00
John Mizerek
c2ae037e71 App Store Version 2: Multi-menu support, beacon lookup, category scheduling
Features:
- Multi-menu support with time-based availability
- Menu hours validation against business operating hours
- Setup wizard now creates Menu records and links categories
- New menus.cfm API for menu CRUD operations
- Category schedule filtering (day/time based visibility)
- Beacon UUID lookup API for customer app
- Parent/child business relationships for franchises
- Category listing API for menu builder

Portal improvements:
- Menu builder theming to match admin UI
- Brand color picker fix
- Header image preview improvements

API fixes:
- Filter demo/hidden businesses from restaurant list
- Improved error handling throughout

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 19:51:44 -08:00