Skip to content

Commit

Permalink
introduce collection_info
Browse files Browse the repository at this point in the history
  • Loading branch information
FuhuXia committed Nov 19, 2024
1 parent 4510c5b commit 5ebb5e8
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions ckanext/geodatagov/plugin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
import hashlib
import urllib.parse
import logging
Expand Down Expand Up @@ -493,11 +494,15 @@ def before_dataset_search(self, search_params):
# TypeError: No object (name: request) has been registered for this thread
path = ''

if 'collection_package_id' not in fq and 'bulk_process' not in path:
log.info('Added FQ to collection_package_id')
fq += ' -collection_package_id:["" TO *]'
else:
log.info('NOT Added FQ to collection_package_id')
if 'collection_info' in fq:
# Replace collection_info with harvest_source_id and isPArtOf
pattern = r'collection_info:"([^"]+?) ([^"]+)"'
fq = re.sub(pattern, r'harvest_source_id:"\1" isPartOf:"\2"', fq)
log.info('FQ changed for collection_info')
elif 'bulk_process' not in path:
# hide collection's children datasets from regular search
fq += ' -isPartOf:["" TO *]'
log.info('Added FQ to hide collection')

search_params['fq'] = fq
return search_params
Expand Down

0 comments on commit 5ebb5e8

Please sign in to comment.