From 7ce0c77a73adf9510b4a7b007cdd59e5913595f2 Mon Sep 17 00:00:00 2001 From: Stephan Porada Date: Wed, 14 Oct 2020 10:42:13 +0200 Subject: [PATCH] Avoid error if query did not yield any results. --- .../static/js/modules/corpus_analysis/client/callbacks.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/web/app/static/js/modules/corpus_analysis/client/callbacks.js b/web/app/static/js/modules/corpus_analysis/client/callbacks.js index e2838204..e5f2e668 100644 --- a/web/app/static/js/modules/corpus_analysis/client/callbacks.js +++ b/web/app/static/js/modules/corpus_analysis/client/callbacks.js @@ -39,16 +39,17 @@ function saveQueryData(...args) { results.data.matches.push(...payload.chunk.matches); results.data.addData(payload.chunk.cpos_lookup, 'cpos_lookup'); results.data.addData(payload.chunk.text_lookup, 'text_lookup'); - console.log(payload.chunk.text_lookup); /** * Increment match_counts per text in a global results varaible because * they are coming in chunkwise. */ - for (let [text_key, value] of Object.entries(payload.chunk.text_lookup)) { + if (payload.chunk.text_lookup) { + for (let [text_key, value] of Object.entries(payload.chunk.text_lookup)) { if (!(text_key in results.tmp_match_counts)) { results.tmp_match_counts[text_key] = {match_count: 0}; } results.tmp_match_counts[text_key].match_count += payload.chunk.text_lookup[text_key].match_count; + } } results.data.cpos_ranges = payload.chunk.cpos_ranges; let queryFormElement = document.querySelector('#query-form');