This is an automated email from the ASF dual-hosted git repository. humbedooh pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git
commit 69411463e453f73ed87bd97114c377e97e24830e Author: Daniel Gruno <[email protected]> AuthorDate: Wed Nov 3 19:56:05 2021 +0100 check for timeouts, skip WC if it happens, rather than erroring out completely. --- server/plugins/messages.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/server/plugins/messages.py b/server/plugins/messages.py index 53f5e9a..8f36ffe 100644 --- a/server/plugins/messages.py +++ b/server/plugins/messages.py @@ -370,19 +370,22 @@ async def wordcloud(session, query_defuzzed): Wordclouds via significant terms query in ES """ wc = {} - res = await session.database.search( - body={ - "size": 0, - "query": {"bool": query_defuzzed}, - "aggregations": { - "cloud": {"significant_terms": {"field": "subject", "size": 10}} - }, - } - ) + try: + res = await session.database.search( + body={ + "size": 0, + "query": {"bool": query_defuzzed}, + "aggregations": { + "cloud": {"significant_terms": {"field": "subject", "size": 10}} + }, + } + ) - for hit in res["aggregations"]["cloud"]["buckets"]: - wc[hit["key"]] = hit["doc_count"] + for hit in res["aggregations"]["cloud"]["buckets"]: + wc[hit["key"]] = hit["doc_count"] + except plugins.database.Timeout as e: # If we time out, just return empty WC. + pass return wc
