Fix price extraction bug and remove debugging statements

This commit is contained in:
2023-08-26 11:05:28 +00:00
parent cd32dff779
commit e10c6f5c46
6 changed files with 10 additions and 25 deletions

View File

@@ -1,6 +1,7 @@
from datetime import datetime
from django.conf import settings
from elastic_transport import ConnectionError
from elasticsearch import Elasticsearch
from core.util import logs
@@ -27,6 +28,10 @@ def store_msg(index, msg):
client = initialise_elasticsearch()
if "ts" not in msg:
msg["ts"] = datetime.utcnow().isoformat()
result = client.index(index=index, body=msg)
try:
result = client.index(index=index, body=msg)
except ConnectionError as e:
log.error(f"Error indexing '{msg}': {e}")
return
if not result["result"] == "created":
log.error(f"Indexing of '{msg}' failed: {result}")