Skip to content

Commit f12ee04

Browse files
committed
refactor: remove stackTraceLine debugging
1 parent d4dfb48 commit f12ee04

15 files changed

+13
-75
lines changed
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
const _ = require('lodash');
22
const Debug = require('../../helper/debug');
33
const debugLog = new Debug('controller:predicates:has_request_errors');
4-
const stackTraceLine = require('../../helper/stackTraceLine');
54

65
module.exports = (req, res) => {
76
const has_request_errors = _.get(req, 'errors', []).length > 0;
87
debugLog.push(req, () => ({
9-
reply: has_request_errors,
10-
stack_trace: stackTraceLine()
8+
reply: has_request_errors
119
}));
1210
return has_request_errors;
1311
};

controller/predicates/hasRequestParameter.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
const _ = require('lodash');
22
const Debug = require('../../helper/debug');
33
const debugLog = new Debug('controller:predicates:has_request_parameter');
4-
const stackTraceLine = require('../../helper/stackTraceLine');
54

65
// returns true IFF req.clean has a key with the supplied name AND a non-empty value
76
module.exports = (parameter) => (req, res) => {
87
const value = _.get(req, ['clean', parameter]);
98
const has_request_parameter = _.isNumber(value) || !_.isEmpty(value);
109

1110
debugLog.push(req, () => ({
12-
reply: {[parameter]: has_request_parameter},
13-
stack_trace: stackTraceLine()
11+
reply: {[parameter]: has_request_parameter}
1412
}));
1513

1614
return has_request_parameter;
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
const _ = require('lodash');
22
const Debug = require('../../helper/debug');
33
const debugLog = new Debug('controller:predicates:has_response_data');
4-
const stackTraceLine = require('../../helper/stackTraceLine');
54

65
module.exports = (request, response) => {
76
const has_response_data = _.get(response, 'data', []).length > 0;
87
debugLog.push(request, () => ({
9-
reply: has_response_data,
10-
stack_trace: stackTraceLine()
8+
reply: has_response_data
119
}));
1210
return has_response_data;
1311
};

controller/predicates/hasResultsAtLayers.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const _ = require('lodash');
22
const Debug = require('../../helper/debug');
33
const debugLog = new Debug('controller:predicates:has_results_at_layers');
4-
const stackTraceLine = require('../../helper/stackTraceLine');
54
// returns a function that returns true if any result.layer is in any of the
65
// supplied layers using array intersection
76

@@ -18,8 +17,7 @@ module.exports = (layers) => {
1817
));
1918

2019
debugLog.push(request, () => ({
21-
reply: {[layers]: has_results_at_layers},
22-
stack_trace: stackTraceLine()
20+
reply: {[layers]: has_results_at_layers}
2321
}));
2422
return has_results_at_layers;
2523
};

controller/predicates/isAdminOnlyAnalysis.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const _ = require('lodash');
22
const Debug = require('../../helper/debug');
33
const debugLog = new Debug('controller:predicates:is_admin_only_analysis');
4-
const stackTraceLine = require('../../helper/stackTraceLine');
54

65
module.exports = (request, response) => {
76
if (!request.clean.hasOwnProperty('parsed_text')) {
@@ -15,8 +14,7 @@ module.exports = (request, response) => {
1514
});
1615

1716
debugLog.push(request, () => ({
18-
reply: is_admin_only_analysis,
19-
stack_trace: stackTraceLine()
17+
reply: is_admin_only_analysis
2018
}));
2119
return is_admin_only_analysis;
2220
};

controller/predicates/isCoarseReverse.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@ const _ = require('lodash');
22
const Debug = require('../../helper/debug');
33
const debugLog = new Debug('controller:predicates:is_coarse_reverse');
44
const non_coarse_layers = ['address', 'street', 'venue'];
5-
const stackTraceLine = require('../../helper/stackTraceLine');
65

76
module.exports = (req, res) => {
87
// returns true if layers is undefined, empty, or contains 'address', 'street', or 'venue'
98
const is_coarse_reverse = !_.isEmpty(req.clean.layers) &&
109
_.isEmpty(_.intersection(req.clean.layers, non_coarse_layers));
1110
debugLog.push(req, () => ({
12-
reply: is_coarse_reverse,
13-
stack_trace: stackTraceLine()
11+
reply: is_coarse_reverse
1412
}));
1513
return is_coarse_reverse;
1614
};
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
const _ = require('lodash');
22
const Debug = require('../../helper/debug');
33
const debugLog = new Debug('controller:predicates:is_only_non_admin_layers');
4-
const stackTraceLine = require('../../helper/stackTraceLine');
54

65
// return true IFF req.clean.layers is empty OR there are non-venue/address/street layers
76
module.exports = (req, res) => {
87
const is_only_non_admin_layers = !_.isEmpty(_.get(req, 'clean.layers', [])) &&
98
_.isEmpty(_.difference(req.clean.layers, ['venue', 'address', 'street']));
109

1110
debugLog.push(req, () => ({
12-
reply: is_only_non_admin_layers,
13-
stack_trace: stackTraceLine()
11+
reply: is_only_non_admin_layers
1412
}));
1513
return is_only_non_admin_layers;
1614
};
Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
const _ = require('lodash');
2-
const Debug = require('../../helper/debug');
3-
const debugLog = new Debug('controller:predicates:is_pelias_parse');
4-
const stackTraceLine = require('../../helper/stackTraceLine');
52

63
// returns true IFF req.clean.parser is pelias
7-
module.exports = (req, res) => {
8-
const is_pelias_parse = _.get(req, 'clean.parser') === 'pelias';
9-
debugLog.push(req, () => ({
10-
reply: is_pelias_parse,
11-
stack_trace: stackTraceLine()
12-
}));
13-
return is_pelias_parse;
4+
module.exports = (req) => {
5+
return _.get(req, 'clean.parser') === 'pelias';
146
};

controller/predicates/isRequestLayersAnyAddressRelated.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const _ = require('lodash');
22
const Debug = require('../../helper/debug');
33
const debugLog = new Debug('controller:predicates:is_request_layers_any_address_related');
4-
const stackTraceLine = require('../../helper/stackTraceLine');
54

65
// return true if any layers allowed by the query are related to an address query
76
// this includes address and street but NOT venue, postalcode, admin, and custom layers
@@ -20,8 +19,7 @@ module.exports = (req, res) => {
2019
}
2120

2221
debugLog.push(req, () => ({
23-
reply: result,
24-
stack_trace: stackTraceLine()
22+
reply: result
2523
}));
2624

2725
return result;
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
const _ = require('lodash');
22
const Debug = require('../../helper/debug');
33
const debugLog = new Debug('controller:predicates:is_request_sources_includes_whosonfirst');
4-
const stackTraceLine = require('../../helper/stackTraceLine');
54

65
// returns true IFF 'whosonfirst' is included in the requested sources
76
module.exports = (req, res) => {
87
const is_request_sources_includes_whosonfirst = _.get(req, 'clean.sources', []).includes(
98
'whosonfirst'
109
);
1110
debugLog.push(req, () => ({
12-
reply: is_request_sources_includes_whosonfirst,
13-
stack_trace: stackTraceLine()
11+
reply: is_request_sources_includes_whosonfirst
1412
}));
1513
return is_request_sources_includes_whosonfirst;
1614
};

0 commit comments

Comments
 (0)