Do not clean up other platforms' trades
This commit is contained in:
parent
6bf3daee4c
commit
d3b4d3ea21
|
@ -677,6 +677,11 @@ class Transactions(util.Base):
|
||||||
return False
|
return False
|
||||||
return tx_data
|
return tx_data
|
||||||
|
|
||||||
|
def get_subclass(self, reference):
|
||||||
|
obj = r.hget(f"trade.{reference}", "subclass")
|
||||||
|
subclass = util.convert(obj)
|
||||||
|
return subclass
|
||||||
|
|
||||||
def del_ref(self, reference):
|
def del_ref(self, reference):
|
||||||
"""
|
"""
|
||||||
Delete a given reference from the Redis database.
|
Delete a given reference from the Redis database.
|
||||||
|
@ -687,7 +692,7 @@ class Transactions(util.Base):
|
||||||
r.delete(f"trade.{reference}")
|
r.delete(f"trade.{reference}")
|
||||||
r.delete(f"trade.{tx}.reference")
|
r.delete(f"trade.{tx}.reference")
|
||||||
|
|
||||||
def cleanup(self, references):
|
def cleanup(self, subclass, references):
|
||||||
"""
|
"""
|
||||||
Reconcile the internal reference database with a given list of references.
|
Reconcile the internal reference database with a given list of references.
|
||||||
Delete all internal references not present in the list and clean up artifacts.
|
Delete all internal references not present in the list and clean up artifacts.
|
||||||
|
@ -696,9 +701,10 @@ class Transactions(util.Base):
|
||||||
"""
|
"""
|
||||||
for tx, reference in self.get_ref_map().items():
|
for tx, reference in self.get_ref_map().items():
|
||||||
if reference not in references:
|
if reference not in references:
|
||||||
self.log.info(f"Archiving trade reference: {reference} / TX: {tx}")
|
if self.get_subclass(reference) == subclass:
|
||||||
r.rename(f"trade.{tx}.reference", f"archive.trade.{tx}.reference")
|
self.log.info(f"Archiving trade reference: {reference} / TX: {tx}")
|
||||||
r.rename(f"trade.{reference}", f"archive.trade.{reference}")
|
r.rename(f"trade.{tx}.reference", f"archive.trade.{tx}.reference")
|
||||||
|
r.rename(f"trade.{reference}", f"archive.trade.{reference}")
|
||||||
|
|
||||||
def tx_to_ref(self, tx):
|
def tx_to_ref(self, tx):
|
||||||
"""
|
"""
|
||||||
|
@ -712,6 +718,7 @@ class Transactions(util.Base):
|
||||||
for reference in refs:
|
for reference in refs:
|
||||||
ref_data = util.convert(r.hgetall(f"trade.{reference}"))
|
ref_data = util.convert(r.hgetall(f"trade.{reference}"))
|
||||||
if not ref_data:
|
if not ref_data:
|
||||||
|
print("NOT REF DATA")
|
||||||
continue
|
continue
|
||||||
if ref_data["id"] == tx:
|
if ref_data["id"] == tx:
|
||||||
return reference
|
return reference
|
||||||
|
|
Loading…
Reference in New Issue