Changeset View
Changeset View
Standalone View
Standalone View
swh/web/common/service.py
Show First 20 Lines • Show All 273 Lines • ▼ Show 20 Lines | def search_origin_metadata(fulltext, limit=50): | ||||
""" | """ | ||||
matches = idx_storage.origin_intrinsic_metadata_search_fulltext( | matches = idx_storage.origin_intrinsic_metadata_search_fulltext( | ||||
conjunction=[fulltext], limit=limit) | conjunction=[fulltext], limit=limit) | ||||
results = [] | results = [] | ||||
for match in matches: | for match in matches: | ||||
match['from_revision'] = hashutil.hash_to_hex(match['from_revision']) | match['from_revision'] = hashutil.hash_to_hex(match['from_revision']) | ||||
origin = None | |||||
if match['origin_url']: | if match['origin_url']: | ||||
origin = storage.origin_get({'url': match['origin_url']}) | origin = storage.origin_get({'url': match['origin_url']}) | ||||
else: | |||||
# Fallback to origin-id for idx-storage with outdated db | |||||
origin = storage.origin_get({'id': match['id']}) | |||||
del match['origin_url'] | del match['origin_url'] | ||||
if 'id' in match: | if 'id' in match: | ||||
del match['id'] | del match['id'] | ||||
result = converters.from_origin(origin) | result = converters.from_origin(origin) | ||||
if result: | if result: | ||||
result['metadata'] = match | result['metadata'] = match | ||||
▲ Show 20 Lines • Show All 821 Lines • Show Last 20 Lines |