From b8cf2ce150e4efef24994526a73bf62b76b313d3 Mon Sep 17 00:00:00 2001 From: John Mizerek Date: Mon, 9 Feb 2026 13:42:19 -0800 Subject: [PATCH] Fix beacon sharding to support Major/Minor starting from 0 - allocate_business_namespace: Start Major from 0 (was 1) - allocate_servicepoint_minor: Start Minor from 0 (was 1) - register_beacon_hardware: Set BeaconMinor if empty instead of rejecting - lookup: Allow Major=0 in validation (was LTE 0, now LT 0) - servicepoints/save: Auto-allocate BeaconMinor on insert, include in response Co-Authored-By: Claude Opus 4.5 --- .../allocate_business_namespace.cfm | 4 +-- .../allocate_servicepoint_minor.cfm | 4 +-- .../register_beacon_hardware.cfm | 9 +++++- api/beacons/lookup.cfm | 2 +- api/servicepoints/save.cfm | 28 +++++++++++++------ 5 files changed, 32 insertions(+), 15 deletions(-) diff --git a/api/beacon-sharding/allocate_business_namespace.cfm b/api/beacon-sharding/allocate_business_namespace.cfm index 86d6bdb..296fa5e 100644 --- a/api/beacon-sharding/allocate_business_namespace.cfm +++ b/api/beacon-sharding/allocate_business_namespace.cfm @@ -117,9 +117,9 @@ if (bizId LTE 0) { - + - SELECT COALESCE(MAX(BeaconMajor), 0) AS MaxMajor + SELECT COALESCE(MAX(BeaconMajor), -1) AS MaxMajor FROM Businesses WHERE BeaconShardID = diff --git a/api/beacon-sharding/allocate_servicepoint_minor.cfm b/api/beacon-sharding/allocate_servicepoint_minor.cfm index a3820ad..9cb33df 100644 --- a/api/beacon-sharding/allocate_servicepoint_minor.cfm +++ b/api/beacon-sharding/allocate_servicepoint_minor.cfm @@ -111,9 +111,9 @@ if (spId LTE 0) { - + - SELECT COALESCE(MAX(BeaconMinor), 0) AS MaxMinor + SELECT COALESCE(MAX(BeaconMinor), -1) AS MaxMinor FROM ServicePoints WHERE BusinessID = diff --git a/api/beacon-sharding/register_beacon_hardware.cfm b/api/beacon-sharding/register_beacon_hardware.cfm index 7ac0f5f..7958318 100644 --- a/api/beacon-sharding/register_beacon_hardware.cfm +++ b/api/beacon-sharding/register_beacon_hardware.cfm @@ -165,7 +165,14 @@ firmwareVersion = normStr(structKeyExists(data, "FirmwareVersion") ? data.Firmwa - + + + + UPDATE ServicePoints + SET BeaconMinor = + WHERE ID = + + - + diff --git a/api/servicepoints/save.cfm b/api/servicepoints/save.cfm index e23fdc1..2a59a8d 100644 --- a/api/servicepoints/save.cfm +++ b/api/servicepoints/save.cfm @@ -89,7 +89,17 @@ if (structKeyExists(data, "IsActive")) { - + + + + SELECT COALESCE(MAX(BeaconMinor), -1) AS MaxMinor + FROM ServicePoints + WHERE BusinessID = + + + + + INSERT INTO ServicePoints ( BusinessID, @@ -97,16 +107,16 @@ if (structKeyExists(data, "IsActive")) { Code, TypeID, IsActive, - SortOrder - , BeaconMinor + SortOrder, + BeaconMinor ) VALUES ( , , , , , - - , + , + ) @@ -136,12 +146,12 @@ if (structKeyExists(data, "IsActive")) { #serializeJSON({ OK=true, ERROR="", SERVICEPOINT=servicePoint })#