Updated the Bureau Router to use persistent RDG (Random Distribution Group) assignment instead of random routing. This ensures that the same ID number always routes to the same bureau, providing consistent user experience and stable load distribution.
Before: Each bureau request generated a new random value (0-100), causing the same ID to potentially route to different bureaus on each call.
After: Each ID receives a permanent RDG value that's stored in the database. The same ID always routes to the same bureau.
Added Method: get_id_number_from_guid()
def get_id_number_from_guid(self, guid):
"""Lookup ID number from GUID in bloom_hcscore table."""
Updated Method: select_bureau_by_rdg()
Old Signature:
def select_bureau_by_rdg(self, strategies)
New Signature:
def select_bureau_by_rdg(self, strategies, id_number)
Changes:
id_number parameterself.random.lookup_rdg(id_number, 'BUREAU_ROUTING', 'RDG1') instead of self.random.randint(0, 100)Updated Method: resolve()
Changes:
if not id_number and guid:
id_number = self.get_id_number_from_guid(guid)
select_bureau_by_rdg(strategies, id_number)Updated Sections:
get_id_number_from_guid(), updated signatures and descriptionsUpdated Sections:
1. def_random - Configuration table (new)
CREATE TABLE def_random (
Package VARCHAR(50) NOT NULL,
RDCode VARCHAR(50) NOT NULL,
PrimaryGuid VARCHAR(50) NOT NULL,
RDGFields INT DEFAULT 1,
Description TEXT,
Active CHAR(1) DEFAULT 'Y',
Created TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
Updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (Package, RDCode)
);
2. Configuration Record
INSERT INTO def_random (Package, RDCode, PrimaryGuid, RDGFields, Description, Active)
VALUES ('homechoice', 'BUREAU_ROUTING', 'idnumber', 1, 'Bureau routing with persistent RDG', 'Y');
3. data_rdg_idnumber - Storage table (created automatically)
CREATE TABLE data_rdg_idnumber (
idnumber VARCHAR(255) NOT NULL,
RDG1 INT DEFAULT NULL,
Created TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
Updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (idnumber)
);
select_bureau_by_rdg(strategies, '8901015800082')ObjRandom.lookup_rdg('8901015800082', 'BUREAU_ROUTING', 'RDG1')INSERT INTO data_rdg_idnumber (idnumber, RDG1) VALUES ('8901015800082', 45)select_bureau_by_rdg(strategies, '8901015800082')ObjRandom.lookup_rdg('8901015800082', 'BUREAU_ROUTING', 'RDG1')Result: Same ID always routes to same bureau!
# Create RDG table manually
python factory.core/ObjRandom.py create-rdg BUREAU_ROUTING
# Test RDG lookup
python factory.core/ObjRandom.py lookup-rdg 8901015800082
# Run test suite
python factory.core/ObjRandom.py test-rdg
Strategy Configuration:
INSERT INTO def_bureau_strategy VALUES ('EXPERIAN', NULL, NULL, 0, 70, NULL, NULL, 'N');
INSERT INTO def_bureau_strategy VALUES ('MYDATA', NULL, NULL, 71, 100, NULL, NULL, 'N');
Results:
Approximately 70% of unique IDs route to EXPERIAN, 30% to MYDATA.
Week 1: 10% to new bureau
DELETE FROM def_bureau_strategy;
INSERT INTO def_bureau_strategy VALUES ('MYDATA', NULL, NULL, 0, 10, NULL, NULL, 'N');
INSERT INTO def_bureau_strategy VALUES ('EXPERIAN', NULL, NULL, 11, 100, NULL, NULL, 'N');
Week 2: Increase to 25%
DELETE FROM def_bureau_strategy;
INSERT INTO def_bureau_strategy VALUES ('MYDATA', NULL, NULL, 0, 25, NULL, NULL, 'N');
INSERT INTO def_bureau_strategy VALUES ('EXPERIAN', NULL, NULL, 26, 100, NULL, NULL, 'N');
Result:
Strategy:
INSERT INTO def_bureau_strategy VALUES ('EXPERIAN', NULL, NULL, 0, 100, 'MYDATA', NULL, 'N');
Behavior:
Possible Causes:
Solution:
# Check configuration
SELECT * FROM def_random WHERE RDCode='BUREAU_ROUTING';
# Check RDG table exists
SHOW TABLES LIKE 'data_rdg_idnumber';
# Check ID has RDG assigned
SELECT * FROM data_rdg_idnumber WHERE idnumber='8901015800082';
# Enable debug logging in router
DO_DEBUG = True
Possible Causes:
Solution:
# Check if ID lookup works
router = ObjServiceBureauRouter()
id_number = router.get_id_number_from_guid(guid)
print(f"ID number: {id_number}")
# Check RDG lookup works
rdg = router.random.lookup_rdg(id_number, 'BUREAU_ROUTING', 'RDG1')
print(f"RDG value: {rdg}")
factory.core/ObjRandom.md - ObjRandom API documentationfactory.core/RDG_USAGE_GUIDE.md - Comprehensive RDG usage guidefactory.service/package.homechoice/ObjServiceBureauRouter.md - Router documentationfactory.service/package.homechoice/BUREAU_FRAMEWORK.md - Framework overview