Skip to content

Commit

Permalink
Merge pull request #22 from PDOK/deterministic-filter
Browse files Browse the repository at this point in the history
make duplicate filter deterministic by sorting on title before filtering
  • Loading branch information
arbakker committed Mar 7, 2023
2 parents fa4cf21 + c86bf3a commit 99276bc
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions ngr_spider/csw_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ def __init__(self, csw_url):
def _filter_service_records(
self, records: list[CswServiceRecord]
) -> list[CswServiceRecord]:
filtered_records = filter(
lambda x: x.service_url != "", records
) # filter out results without serviceurl
records.sort(key=lambda x: x.title, reverse=True)
filtered_records = filter(lambda x: x.service_url != "", records)

# filter out results without serviceurl
# delete duplicate service entries, some service endpoint have multiple service records
# so last record in get_record_results will be retained in case of duplicate
# since it will be inserted in new_dict last
Expand Down Expand Up @@ -66,8 +67,10 @@ def _get_csw_records_by_protocol(
) -> list[CswServiceRecord]:

protocol_key = "protocol"
if protocol == OAT_PROTOCOL: # required since NGR does not support OGC API TILES as a seperate protocol
protocol_key= "anyText"
if (
protocol == OAT_PROTOCOL
): # required since NGR does not support OGC API TILES as a seperate protocol
protocol_key = "anyText"

query = f"type='service' AND organisationName='{svc_owner}' AND {protocol_key}='{protocol}'"
records = self._get_csw_records(query, max_results, no_filter)
Expand Down

0 comments on commit 99276bc

Please sign in to comment.