Unverified Commit 98fa99f6 authored by Sebastian Schüpbach's avatar Sebastian Schüpbach
Browse files

fix record_values processing


Signed-off-by: Sebastian Schüpbach's avatarSebastian Schüpbach <sebastian.schuepbach@unibas.ch>
parent a6cdad23
Pipeline #16772 failed with stages
in 1 minute and 33 seconds
......@@ -342,15 +342,15 @@ class MediametadataToDB:
_write_values_in_db(mariadb_cursor, record_values_for_db)
mariadb_connection.commit()
for record_value in record_values_for_db:
logging.info(f'Record {record_value["@id"]} successfully indexed')
reporter.send_message(record_value['@id'], "SUCCESS", "Indexing successful")
logging.info(f'Record {record_value["sig"]} successfully indexed')
reporter.send_message(record_value['sig'], "SUCCESS", "Indexing successful")
record_values_for_db = []
consumer.commit()
except Exception as ex:
status = 'It was not possible to consume the Kafka messages.' + '\n' + str(ex)
logging.error(status)
for record_value in record_values_for_db:
reporter.send_message(record_value['@id'], "FAILURE", f"Indexing failed: {ex}")
reporter.send_message(record_value['sig'], "FAILURE", f"Indexing failed: {ex}")
def __init__(self):
# TODO : maybe take that to a configuration (development vs pod running in
......
......@@ -70,7 +70,7 @@ class Reporter:
now = datetime.datetime.now()
# //@formatter:off
timestamp = now.strftime('%Y-%m-%dT%H:%M:%S.') + \
str(round(int(now.strftime('%f')) / 1000))
str(round(int(now.strftime('%f')) / 1000))
# //@formatter:on
report = {
'id': identifier,
......@@ -79,7 +79,9 @@ class Reporter:
'step': 'mediametadatatodb',
'timestamp': timestamp
}
value_bytes = bytes(json.dumps(report), encoding='utf-8')
json_report = json.dumps(report)
value_bytes = bytes(json_report, encoding='utf-8')
logging.debug(f'Sending report to {os.environ["REPORTING_TOPIC"]}: {json_report}')
self._producer.send(os.environ['REPORTING_TOPIC'], key=key_bytes, value=value_bytes)
self._producer.flush()
except Exception as ex:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment