From fe020ba383bd59f7eb4a4ec70579518e16212aa2 Mon Sep 17 00:00:00 2001 From: AccentuSoft Date: Mon, 29 Aug 2022 03:30:40 +0300 Subject: [PATCH] Small improvements to Aleph resolutions. --- Modules/Aleph/Aleph_Entity_Search.py | 15 +++++++++------ Modules/Aleph/GetCollectionsInfo.py | 12 ++++-------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/Modules/Aleph/Aleph_Entity_Search.py b/Modules/Aleph/Aleph_Entity_Search.py index fdfcb52..e6ebf9e 100644 --- a/Modules/Aleph/Aleph_Entity_Search.py +++ b/Modules/Aleph/Aleph_Entity_Search.py @@ -7,11 +7,10 @@ class Aleph_Entity_Search: description = "Find information about a given search parameter" originTypes = {'Phrase', 'Person', 'Politically Exposed Person'} resultTypes = {'Phrase'} - parameters = {'Number of results': {'description': 'Creating a lot of nodes could slow down the software. Please ' - 'be mindful of the value you enter.', - 'type': 'String', - 'value': 'Enter the number of results you want returned', - 'default': '1'}, + parameters = {'Max Results': {'description': 'The maximum number of results to return.', + 'type': 'String', + 'value': 'Enter the number of results you want returned', + 'default': '1'}, 'Aleph Disclaimer': {'description': 'The content on Aleph is provided for general information only.\n' 'It is not intended to amount to advice on which you should place' 'sole and entire reliance.\n' @@ -43,9 +42,13 @@ class Aleph_Entity_Search: return "Please Accept the Terms for Aleph." try: - max_results = int(parameters['Number of results']) + max_results = int(parameters['Max Results']) except ValueError: return "The value for parameter 'Max Results' is not a valid integer." + + if max_results <= 0: + return [] + with FuturesSession(max_workers=15) as session: for entity in entityJsonList: uidList.append(entity['uid']) diff --git a/Modules/Aleph/GetCollectionsInfo.py b/Modules/Aleph/GetCollectionsInfo.py index 3d7a0b6..6a8d133 100644 --- a/Modules/Aleph/GetCollectionsInfo.py +++ b/Modules/Aleph/GetCollectionsInfo.py @@ -7,7 +7,7 @@ class GetCollectionsInfo: description = "Find information about Collections and their IDs" originTypes = {'Phrase'} resultTypes = {'Phrase, Aleph ID'} - parameters = {'Max Results': {'description': 'Please enter the maximum number of results to return. ', + parameters = {'Max Results': {'description': 'Please enter the maximum number of results to return.', 'type': 'String', 'default': '1'}, 'Aleph Disclaimer': {'description': 'The content on Aleph is provided for general information only.\n' @@ -38,10 +38,10 @@ class GetCollectionsInfo: headers = {'Content-type': 'application/json', 'Accept': 'text/plain'} try: - linkNumbers = int(parameters['Max Results']) + maxResults = int(parameters['Max Results']) except ValueError: return "The value for parameter 'Max Results' is not a valid integer." - if linkNumbers <= 0: + if maxResults <= 0: return [] with FuturesSession(max_workers=15) as session: for entity in entityJsonList: @@ -56,11 +56,7 @@ class GetCollectionsInfo: except requests.exceptions.ConnectionError: return "Please check your internet connection" - max_results = int(len(response['results'])) - if linkNumbers >= max_results: - collections = response['results'] - else: - collections = response['results'][0: linkNumbers] + collections = response['results'][:maxResults] for collection in collections: index_of_child = len(returnResults)