Skip to content

Commit 941b406

Browse files
committed
Fixed Hit Count Error
modified: scripts/field.py modified: scripts/utils.py
1 parent a9d2408 commit 941b406

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

scripts/field.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,6 @@ def add_field(self, **kwargs):
213213
def get_eod_fieldnames(self, sort=False, lowered=False):
214214
"""
215215
Gets the list of EOD fieldnames.
216-
217-
:param sort: Determines whether to sort the list of fieldnames alphabetically.
218-
:type sort: boolean
219-
:param lowered: Determines whether to return the fieldnames in lowercase.
220-
:type lowered: boolean
221216
222217
:return: A list of EOD filenames.
223218
:rtype: list

scripts/utils.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -830,16 +830,18 @@ def check_hit_count(self):
830830
filters = self.rapi_search_args.get('filters')
831831
features = self.rapi_search_args.get('features')
832832
dates = self.rapi_search_args.get('dates')
833-
resultFields = self.rapi_search_args.get('resultFields')
834-
maxResults = self.rapi_search_args.get('maxResults')
833+
result_fields = self.rapi_search_args.get('resultFields')
834+
max_res = self.rapi_search_args.get('maxResults')
835835

836836
# Get hit count
837837
print(f"\nGetting hit count...")
838838
hit_count = self.eodms_rapi.search(self.coll_id, filters, features,
839-
dates, resultFields, maxResults,
840-
True).get('hitCount')
839+
dates, result_fields, max_res,
840+
hit_count=True).get('hitCount')
841841

842-
print(f"Hit Count for Search: {hit_count}")
842+
msg = f"Hit Count for Search: {hit_count}"
843+
print(f"\n{msg}")
844+
self.logger.info(msg)
843845

844846
return hit_count
845847

@@ -1520,17 +1522,18 @@ def query_entries(self, collections, **kwargs):
15201522
for k, v in self.rapi_search_args.items():
15211523
print(f" {k}: {v}")
15221524

1523-
if max_images is None or max_images == '':
1524-
# Check hit count for the search
1525-
hit_count = self.check_hit_count()
1526-
max_images = hit_count
1525+
# Check hit count for the search
1526+
hit_count = self.check_hit_count()
15271527

15281528
if hit_count == 0:
15291529
msg = "Sorry, no results found for given AOI or filters."
15301530
self.print_msg(msg, heading="warning")
15311531
self.logger.warning(msg)
15321532
self.exit_cli()
15331533

1534+
if max_images is None or max_images == '' or max_images > hit_count:
1535+
max_images = hit_count
1536+
15341537
if max_images > 1500:
15351538
msg = f"""The hit count for this search is too high. The RAPI will most likely timeout.
15361539
Please separate your searches into separate commands, narrowing your searches with other filters (such as adding a date range(s)).

0 commit comments

Comments
 (0)