Skip to content

Commit

Permalink
Merge pull request #16 from biothings/fix_logs
Browse files Browse the repository at this point in the history
fix: ✨ fix repeating predicate restriction logs
  • Loading branch information
marcodarko authored Jun 22, 2021
2 parents 73f3c6f + 4b10df0 commit 244fb3c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/batch_edge_query.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ module.exports = class BatchEdgeQueryHandler {
* @private
*/
async _postQueryFilter(response) {
let filters_applied = new Set();
try {
const filtered = response.filter((item) => {
if (
Expand All @@ -62,6 +63,7 @@ module.exports = class BatchEdgeQueryHandler {
if (predicate_filters) {
//add query predicate to the expanded list
predicate_filters.concat(edge_predicate);
predicate_filters.forEach((f) => filters_applied.add(f));
//remove prefix from filter list to match predicate name format
predicate_filters = predicate_filters.map((item) => utils.removeBioLinkPrefix(item));
//compare edge predicate to filter list
Expand All @@ -78,19 +80,21 @@ module.exports = class BatchEdgeQueryHandler {
}
});
// filter result
debug(`Filtered results from ${response.length} down to ${filtered.length} results`);
debug(`Filters applied to search: ${JSON.stringify([...filters_applied])}`);
this.logs.push(
new LogEntry(
'DEBUG',
null,
`query_graph_handler: Total number of results returned for this query is ${response.length}.`,
`query_graph_handler: Post-query predicate restrictions: ${JSON.stringify([...filters_applied])}.`,
).getLog(),
);
// filter result
debug(`Filtered results from ${response.length} down to ${filtered.length} results`);
this.logs.push(
new LogEntry(
'DEBUG',
null,
`query_graph_handler: Successfully applied post-query predicate restriction with ${filtered.length} results.`,
`query_graph_handler: Successfully applied post-query predicate restriction: ${response.length} down to ${filtered.length} results.`,
).getLog(),
);
return filtered;
Expand Down

0 comments on commit 244fb3c

Please sign in to comment.