Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ✨ fix repeating predicate restriction logs #16

Merged
merged 1 commit into from
Jun 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading