From b584506673e3bb073241409b55e601fd2f3c46c6 Mon Sep 17 00:00:00 2001 From: m5r Date: Wed, 27 Nov 2024 15:43:10 +0100 Subject: [PATCH] get rid of debugging logs --- .../nouveau/contacts_by_freetext/index.js | 17 ++++++----------- .../contacts_by_type_freetext/index.js | 19 ++++++++----------- .../nouveau/reports_by_freetext/index.js | 7 ------- 3 files changed, 14 insertions(+), 29 deletions(-) diff --git a/ddocs/medic-db/medic-nouveau/nouveau/contacts_by_freetext/index.js b/ddocs/medic-db/medic-nouveau/nouveau/contacts_by_freetext/index.js index 03300c6004..a322659b62 100644 --- a/ddocs/medic-db/medic-nouveau/nouveau/contacts_by_freetext/index.js +++ b/ddocs/medic-db/medic-nouveau/nouveau/contacts_by_freetext/index.js @@ -1,9 +1,9 @@ function (doc) { - const skip = ['_id', '_rev', 'type', 'refid', 'geolocation']; - let toIndex = ''; + var skip = ['_id', '_rev', 'type', 'refid', 'geolocation']; + var toIndex = ''; - const types = ['district_hospital', 'health_center', 'clinic', 'person']; - let idx; + var types = ['district_hospital', 'health_center', 'clinic', 'person']; + var idx; if (doc.type === 'contact') { idx = types.indexOf(doc.contact_type); if (idx === -1) { @@ -13,10 +13,10 @@ function (doc) { idx = types.indexOf(doc.type); } - const isContactDoc = idx !== -1; + var isContactDoc = idx !== -1; if (isContactDoc) { Object.keys(doc).forEach(function (key) { - const value = doc[key]; + var value = doc[key]; if (!key || !value) { return; } @@ -26,11 +26,6 @@ function (doc) { return; } - const fieldNameRegex = /^\$?[a-zA-Z][a-zA-Z0-9_]*$/g - if (!fieldNameRegex.test(key)) { - log(`key "${key}" doesn't pass regex - "${doc.id}"`); - } - if (typeof value === 'string') { toIndex += ' ' + value; index('text', key, value, { store: true }); diff --git a/ddocs/medic-db/medic-nouveau/nouveau/contacts_by_type_freetext/index.js b/ddocs/medic-db/medic-nouveau/nouveau/contacts_by_type_freetext/index.js index 4d8033ed83..777dd18848 100644 --- a/ddocs/medic-db/medic-nouveau/nouveau/contacts_by_type_freetext/index.js +++ b/ddocs/medic-db/medic-nouveau/nouveau/contacts_by_type_freetext/index.js @@ -1,6 +1,6 @@ function (doc) { var skip = ['_id', '_rev', 'type', 'refid', 'geolocation']; - let toIndex = ''; + var toIndex = ''; var types = ['district_hospital', 'health_center', 'clinic', 'person']; var idx; @@ -15,7 +15,9 @@ function (doc) { type = doc.type; idx = types.indexOf(type); } - if (idx !== -1) { + + var isContactDoc = idx !== -1; + if (isContactDoc) { Object.keys(doc).forEach(function (key) { var value = doc[key]; if (!key || !value) { @@ -27,11 +29,6 @@ function (doc) { return; } - const fieldNameRegex = /^\$?[a-zA-Z][a-zA-Z0-9_]*$/g - if (!fieldNameRegex.test(key)) { - log(`key "${key}" doesn't pass regex - "${doc.id}"`); - } - if (typeof value === 'string') { toIndex += ' ' + value; index('text', key, value, { store: true }); @@ -41,10 +38,10 @@ function (doc) { index('double', key, value, { store: true }); } }); - } - toIndex = toIndex.trim(); - if (toIndex) { - index('text', 'default', toIndex, { store: true }); + toIndex = toIndex.trim(); + if (toIndex) { + index('text', 'default', toIndex, { store: true }); + } } } diff --git a/ddocs/medic-db/medic-nouveau/nouveau/reports_by_freetext/index.js b/ddocs/medic-db/medic-nouveau/nouveau/reports_by_freetext/index.js index 99f5eb7038..3e901ea159 100644 --- a/ddocs/medic-db/medic-nouveau/nouveau/reports_by_freetext/index.js +++ b/ddocs/medic-db/medic-nouveau/nouveau/reports_by_freetext/index.js @@ -12,11 +12,6 @@ function (doc) { return; } - var fieldNameRegex = /^\$?[a-zA-Z][a-zA-Z0-9_]*$/g - if (!fieldNameRegex.test(key)) { - log(`key "${key}" doesn't pass regex - "${doc._id}"`); - } - if (typeof value === 'string') { toIndex += ' ' + value; index('text', key, value, { store: true }); @@ -40,8 +35,6 @@ function (doc) { toIndex = toIndex.trim(); if (toIndex) { index('text', 'default', toIndex, { store: true }); - } else { - log(`******* empty toIndex "${toIndex}" "${doc._id}"`); } } }