Skip to content

Commit

Permalink
Revert "Revert "Updated code for data type of offset and length""
Browse files Browse the repository at this point in the history
This reverts commit 897a910.
  • Loading branch information
JyotiWhcl committed Nov 19, 2021
1 parent ca9282c commit 98f1b73
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@ def __init__(self, api_client):

def create_results_connection(self, search_id, offset, length):
try:
min_range = int(offset)
max_range = min_range + int(length)

min_range = offset
max_range = offset + length
# Grab the response, extract the response code, and convert it to readable json
response = self.api_client.get_search_results(search_id)
response_code = response.code
response_txt = response.read()
# Construct a response object
# print("response code={}, text={}".format(response_code, response_txt))
return_obj = dict()
error_obj = dict()
if response_code == 200:
Expand All @@ -33,16 +31,15 @@ def create_results_connection(self, search_id, offset, length):
if isinstance(value, list) and value:
newdata+=value

# slice off the data count according to offset values
if newdata and min_range > 0 and max_range > 0 and len(newdata) > max_range:
newdata = newdata[min_range:max_range]
# slice of the data count according to offset values
if newdata and max_range > 0 and len(newdata) > max_range:
newdata = newdata[:max_range]

for msg in newdata:
if "messageParts" in msg:
msg["is_multipart"] = True
else: msg["is_multipart"] = False

print("newdata :", newdata)
return_obj['data'] = newdata

except json.decoder.JSONDecodeError as err:
Expand Down

0 comments on commit 98f1b73

Please sign in to comment.