Skip to content

Commit

Permalink
Merge pull request #35 from PDOK/PDOK-16505_ngr_spider_upgrade
Browse files Browse the repository at this point in the history
extra check op aantal records vanwege bug in GetRecords GeoNetwork
  • Loading branch information
kad-velsl authored Apr 23, 2024
2 parents bb2f862 + 6c0b123 commit 90750a3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ngr_spider/csw_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ def _get_csw_records(
self, query: str, maxresults: int = 0, no_filter: bool = False
) -> list[CswServiceRecord]:
csw = CatalogueServiceWeb(self.csw_url)

while True:
result: list[CswServiceRecord] = []
start = 1
Expand All @@ -49,14 +48,15 @@ def _get_csw_records(
)
if start == 1:
matched = csw.results["matches"]
LOGGER.info("Number of matched servcies before filtering: " + str(matched))
LOGGER.info("Number of matched services before filtering: " + str(matched))
elif matched != csw.results["matches"]:
LOGGER.info("Number of matched servcies has been changed: old = " + str(matched) + ", new = " + str(csw.results["matches"]))
LOGGER.info("Number of matched services has been changed: old = " + str(matched) + ", new = " + str(csw.results["matches"]))
break # inner loop

records = [CswServiceRecord(rec[1].xml) for rec in csw.records.items()]
result.extend(records)
if csw.results["nextrecord"] != 0 and (maxresults == 0 or len(result) < maxresults):
# extra check op aantal records groter dan nextrecord vanwege bug in GeoNetwork
if (csw.results["nextrecord"] != 0 and csw.results["nextrecord"] < csw.results["matches"]) and (maxresults == 0 or len(result) < maxresults):
start = csw.results["nextrecord"]
continue
result_out: list[CswServiceRecord] = result
Expand Down

0 comments on commit 90750a3

Please sign in to comment.