add disabled and fulfilled
This commit is contained in:
@@ -7,6 +7,7 @@ class Condition:
|
||||
condition: str
|
||||
value: float
|
||||
disabled: bool
|
||||
fulfilled: bool
|
||||
|
||||
@staticmethod
|
||||
def lower_than(value: float, lastPrice: float):
|
||||
|
||||
+10
-2
@@ -41,13 +41,13 @@ class DbConnector:
|
||||
conditions = fetch_conditions()
|
||||
|
||||
for cond in conditions:
|
||||
if not cond.disabled:
|
||||
if not cond.disabled and not cond.fulfilled:
|
||||
callback(cond)
|
||||
|
||||
feed = r.table(TABLE_NAME).changes().run(get_connection())
|
||||
for change in feed:
|
||||
cond = Condition(**change['new_val'])
|
||||
if not cond.disabled:
|
||||
if not cond.disabled and not cond.fulfilled:
|
||||
callback(cond)
|
||||
|
||||
@staticmethod
|
||||
@@ -56,4 +56,12 @@ class DbConnector:
|
||||
json = jsonify(cursor)
|
||||
json.disabled = True
|
||||
r.table(TABLE_NAME).get(condition_id).update(json).run(get_connection())
|
||||
|
||||
@staticmethod
|
||||
def fulfill_condition(condition_id: str):
|
||||
cursor = r.table(TABLE_NAME).get(condition_id).run(get_connection())
|
||||
json = jsonify(cursor)
|
||||
json.disabled = True
|
||||
json.fulfilled = True
|
||||
r.table(TABLE_NAME).get(condition_id).update(json).run(get_connection())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user