Skip to content

Commit

Permalink
get rid of debugging logs
Browse files Browse the repository at this point in the history
  • Loading branch information
m5r committed Nov 27, 2024
1 parent c866871 commit b584506
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 29 deletions.
17 changes: 6 additions & 11 deletions ddocs/medic-db/medic-nouveau/nouveau/contacts_by_freetext/index.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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;
}
Expand All @@ -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 });
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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) {
Expand All @@ -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 });
Expand All @@ -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 });
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand All @@ -40,8 +35,6 @@ function (doc) {
toIndex = toIndex.trim();
if (toIndex) {
index('text', 'default', toIndex, { store: true });
} else {
log(`******* empty toIndex "${toIndex}" "${doc._id}"`);
}
}
}

0 comments on commit b584506

Please sign in to comment.