diff --git a/adsmp/tasks.py b/adsmp/tasks.py index e126a25..b60fcc4 100644 --- a/adsmp/tasks.py +++ b/adsmp/tasks.py @@ -157,6 +157,7 @@ def task_update_record(msg): record = app.update_storage(m.bibcode, 'nonbib_data', m.toJSON()) if record: logger.debug('Saved record from list: %s', record) + _generate_boost_request(m, type) elif type == 'metrics_records': for m in msg.metrics_records: m = Msg(m, None, None) @@ -164,12 +165,14 @@ def task_update_record(msg): record = app.update_storage(m.bibcode, 'metrics', m.toJSON(including_default_value_fields=True)) if record: logger.debug('Saved record from list: %s', record) + _generate_boost_request(m, type) elif type == 'augment': bibcodes.append(msg.bibcode) record = app.update_storage(msg.bibcode, 'augment', msg.toJSON(including_default_value_fields=True)) if record: logger.debug('Saved augment message: %s', msg) + _generate_boost_request(msg, type) elif type == 'classify': bibcodes.append(msg.bibcode) logger.debug(f'message to JSON: {msg.toJSON(including_default_value_fields=True)}') @@ -178,28 +181,32 @@ def task_update_record(msg): record = app.update_storage(msg.bibcode, 'classify',payload) if record: logger.debug('Saved classify message: %s', msg) + _generate_boost_request(msg, type) else: # here when record has a single bibcode bibcodes.append(msg.bibcode) record = app.update_storage(msg.bibcode, type, msg.toJSON()) if record: logger.debug('Saved record: %s', record) + _generate_boost_request(msg, type) if type == 'metadata': # with new bib data we request to augment the affiliation # that pipeline will eventually respond with a msg to task_update_record logger.debug('requesting affilation augmentation for %s', msg.bibcode) app.request_aff_augment(msg.bibcode) - if record: - # Send payload to Boost pipeline - if type != 'boost' and not app._config.get('TESTING_MODE', False): - try: - task_boost_request.apply_async(args=(msg.bibcode,)) - except Exception as e: - app.logger.exception('Error generating boost request message for bibcode %s: %s', msg.bibcode, e) - else: logger.error('Received a message with unclear status: %s', msg) +def _generate_boost_request(msg, msg_type): + # Send payload to Boost pipeline + if msg_type not in app._config.get('IGNORED_BOOST_PAYLOAD_TYPES', ['boost']) and not app._config.get('TESTING_MODE', False): + try: + task_boost_request.apply_async(args=(msg.bibcode,)) + except Exception as e: + app.logger.exception('Error generating boost request message for bibcode %s: %s', msg.bibcode, e) + else: + app.logger.debug("Message for bibcode %s has type: %s, Skipping.".format(msg.bibcode, msg_type)) + @app.task(queue='update-scixid') def task_update_scixid(bibcodes, flag): """Receives bibcodes to add scix id to the record. diff --git a/config.py b/config.py index bd4ba64..b4934cb 100644 --- a/config.py +++ b/config.py @@ -31,7 +31,7 @@ # db connection to the Boost Pipeline database where boost factors are stored # if not present, boost factors will not be included in SOLR documents BOOST_SQLALCHEMY_URL = None #'postgresql://boost_user:boost_pass@localhost:5432/boost_db' - +IGNORED_BOOST_PAYLOAD_TYPES = ["boost"] # Main Solr # SOLR_URLS = ["http://localhost:9983/solr/collection1/update"]