Store cheat output in ES

This commit is contained in:
Mark Veidemanis 2022-02-24 23:44:10 +00:00
parent 9ef7f952f7
commit 3ff4d512a4
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
2 changed files with 20 additions and 0 deletions

View File

@ -378,6 +378,7 @@ class Agora(object):
ads = self.money.lookup_rates(ads_list, rates=rates)
if not ads:
continue
self.write_to_es_ads("ads", ads)
if currency in public_ads:
for ad in list(ads):
if ad not in public_ads[currency]:
@ -387,6 +388,24 @@ class Agora(object):
return public_ads
def write_to_es_ads(self, msgtype, ads):
if settings.ES.Enabled == "1":
for ad in ads:
cast = {
"id": ad[0],
"username": ad[1],
"price": ad[2],
"provider": ad[3],
"asset": ad[4],
"currency": ad[5],
"margin": ad[6],
}
cast["type"] = msgtype
cast["ts"] = str(datetime.now().isoformat())
cast["xtype"] = "platorm"
cast["market"] = "agora"
self.es.index(index=settings.ES.MetaIndex, document=cast)
def slow_ad_update(self, ads):
"""
Slow ad equation update utilising exponential backoff in order to guarantee all ads are updated.

View File

@ -60,6 +60,7 @@ class Transactions(object):
self.lc_es_checks = LoopingCall(self.run_checks_in_thread)
delay = int(settings.ES.RefreshSec)
self.lc_es_checks.start(delay)
self.agora.es = self.es
# TODO: write tests then refactor, this is terribly complicated!
def transaction(self, data):