From e1085ef03fe357adb7205d004db2d9508af7cbd6 Mon Sep 17 00:00:00 2001 From: Tom Kralidis Date: Wed, 6 Nov 2024 06:43:42 -0500 Subject: [PATCH] Revert "always update Pub/Sub links to GBs (#23)" This reverts commit c14cff01da2241604c3b7a21bc07d0cb590798f1. --- wis2-gdc-management/wis2_gdc/registrar.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/wis2-gdc-management/wis2_gdc/registrar.py b/wis2-gdc-management/wis2_gdc/registrar.py index f5bbc03..096e454 100644 --- a/wis2-gdc-management/wis2_gdc/registrar.py +++ b/wis2-gdc-management/wis2_gdc/registrar.py @@ -213,8 +213,9 @@ def register(self, metadata: Union[dict, str], topic: str = None) -> None: self._process_record_metric( self.metadata['id'], f'{data_policy}_total', centre_id_labels) - LOGGER.info('Updating links') - self.update_record_links(data_policy) + if data_policy == 'core': + LOGGER.info('Core data detected: updating links') + self.update_record_links() LOGGER.info('Publishing metadata to backend') self._publish() @@ -359,7 +360,7 @@ def _publish(self): LOGGER.info(f'Saving to {BACKEND_TYPE} ({BACKEND_CONNECTION})') self.backend.save_record(self.metadata) - def update_record_links(self, data_policy: str) -> None: + def update_record_links(self) -> None: """ Update Global Service links @@ -378,15 +379,11 @@ def is_wis2_mqtt_link(link) -> bool: for count, value in enumerate(self.metadata['links']): if is_wis2_mqtt_link(value): LOGGER.debug('Adjusting MQTT link') - channel = value.get('channel', value.get('wmo:topic')) + channel = value.get('wmo:topic', value.get('channel')) new_link = value _ = new_link.pop('wmo:topic', None) - if data_policy == 'core': - LOGGER.debug('Adjusting channel origin to cache') - new_link['channel'] = channel.replace('origin', 'cache') - new_link['rel'] = 'items' new_link['channel'] = channel.replace('origin', 'cache') new_link['type'] = 'application/geo+json'