wjf loader: import active machines only (isactive=1)
Classic ASP keeps retired machines in the machines table as history (isactive=0); every other stage already filters isactive=1, but the assets hub, metrology, locations and the verify count read machines unfiltered, so ~240 retired units (incl. all G-prefix hostnames and 61 dead metrology PCs that each synthesized a phantom measuring tool) landed as live assets. Add the isactive=1 filter to those four queries. Downstream stages resolve via the id crosswalk, so warranties /comms/relationships/installs for retired machines now drop automatically.
This commit is contained in:
@@ -234,7 +234,10 @@ def stage_assets(h):
|
||||
"""The hub: fan classic machines out to the right asset endpoint by type,
|
||||
persisting the machineid -> assetid crosswalk everything downstream needs.
|
||||
LocationOnly/printer/usb rows are skipped here (handled elsewhere / TODO)."""
|
||||
machines = h.source.rows('shopdb_src', 'SELECT * FROM machines')
|
||||
# isactive=1 only: retired machines (classic keeps them as history) must not
|
||||
# land as live assets. Every other stage already filters isactive=1; the
|
||||
# assets hub is the one that leaked retired rows (incl. G-prefix hostnames).
|
||||
machines = h.source.rows('shopdb_src', 'SELECT * FROM machines WHERE isactive=1')
|
||||
seen_assetnumbers = set()
|
||||
counts = {'computer': 0, 'machine': 0, 'network': 0, 'measuringtool': 0,
|
||||
'skip_location': 0, 'skip_other': 0, 'skip_dup': 0, 'skip_9999': 0}
|
||||
@@ -367,6 +370,7 @@ def stage_metrology(h):
|
||||
'SELECT machineid, alias, hostname, machinenumber, businessunitid, '
|
||||
'mapleft, maptop, pctypeid FROM machines '
|
||||
'WHERE machinetypeid=33 AND pctypeid IN (5,6,7,8) '
|
||||
'AND isactive=1 '
|
||||
'AND (islocationonly IS NULL OR islocationonly=0)'):
|
||||
pc_assetid = h.ids.get('asset', m['machineid'])
|
||||
if not pc_assetid:
|
||||
@@ -597,7 +601,7 @@ def stage_locations(h):
|
||||
made = 0
|
||||
for m in h.source.rows('shopdb_src',
|
||||
'SELECT machineid, machinenumber, alias FROM machines '
|
||||
'WHERE machinetypeid=1 AND islocationonly=1'):
|
||||
'WHERE machinetypeid=1 AND islocationonly=1 AND isactive=1'):
|
||||
name = (m['alias'] or m['machinenumber'] or '').strip()
|
||||
if not name:
|
||||
continue
|
||||
@@ -746,7 +750,7 @@ def stage_verify(h):
|
||||
"""Row-count audit: source active count vs target count for each entity."""
|
||||
checks = [
|
||||
('vendors', 'shopdb_src', 'SELECT COUNT(*) c FROM vendors WHERE isactive=1', 'vendors'),
|
||||
('assets', 'shopdb_src', 'SELECT COUNT(*) c FROM machines', 'assets'),
|
||||
('assets', 'shopdb_src', 'SELECT COUNT(*) c FROM machines WHERE isactive=1', 'assets'),
|
||||
('applications', 'shopdb_src', 'SELECT COUNT(*) c FROM applications WHERE isactive=1', 'applications'),
|
||||
('knowledgebase', 'shopdb_src', 'SELECT COUNT(*) c FROM knowledgebase WHERE isactive=1', 'knowledgebase'),
|
||||
('employees', 'wjf_employees_src', 'SELECT COUNT(*) c FROM employees', 'directoryemployees'),
|
||||
|
||||
Reference in New Issue
Block a user